Wizards of the Coast has some great in-depth rules for mass combat via their quasi-official Unearthed Arcana section. But for a recent session I played, I wanted something a little simpler that didn't require the players to learn entirely new mechanics. Here's what I came up with.
As in most mass combat hacks, one figure represents multiple creatures. It's all arbitrary, but you'll need to decide how many creatures form a unit. If you're representing two armies with thousands of troops, you'll probably want to do 100 or even 500 creatures per unit, while for a smaller battle like I ran above, I had about 30 units of 10 creatures each.
This will inform the battlefield scale. I recommend using 1 in. equals 50 ft. if your units are under 100 creatures; 1 in. equals 100 ft. for 100-399 creatures; and 1 in. equals 500 ft. for 400-10,000 creatures. No matter the size of the unit within those ranges, go ahead and have them take up a 1 in. space (for medium creatures).
Note that for the smallest scale, you may need a very large map or deal with the fact that siege weapons and longbows will be able to target a vast majority of the area. For my small-scale test battle I had done a scale of 1" equals 30 ft. and this proved to be a little too zoomed in.
For these rules, each round lasts for one minute rather than six seconds. This means that units move ten times their normal speed in a round, working very nicely with scales of 50/100/500 ft. instead of 5 ft.
The rest of combat is run the same way as normal, treating each unit as an individual creature, with only a few exceptions.
Obviously we don't want to make ten sets of attacks to represent the full length of a one minute round. Treat the round as normal, but any missed attacks do half damage. This represents that a unit that "misses" on an attack is still harming their target, just not as effectively as possible.
When a unit is reduced to half of its starting hit points or lower, it makes all future ability checks and attack rolls with disadvantage and attacks against it have advantage. In addition, it must succeed on a DC 10 Charisma saving throw or else become routed. Routed units must use their full movement and the Dash or Disengage action to flee to safety. Any attack against a routed unit automatically hits. Routed units can repeat the Charisma saving throw at the end of their turn.
If you plan on making large battles a focal point of your campaign, I absolutely encourage you to use a more robust ruleset, whether that's Unearthed Arcana, Warhammer Fantasy Battles, or something custom you come up with yourself. But if you're planning on just running a single set piece mini-game, I recommend keeping things simple for your players, while adding just a few rules to make it special.