In order to properly understand templars, one should first look at the 2e AD&D class structure and the Dark Sun-specific differences. I'll spoiler that for those who already know the pecularitiese of 2e:
[sblock]In 2e, there were four different "class groups": Warrior, Priest, Rogue, and Wizard (with Psionicist added in the Complete Psionics Handbook). The class group generally determined the basic abilities of the class: HD, THAC0, Saving Throws, and XP table (though there you had some variety within the class group as well).
All divine casters used the same spell list, but had access to different sub-sets of the list, called Spheres. So a priest of Thor might have access to priest spells that enhanced his or her allies in combat, and controlled the weather, and probably some healing as well because pretty much all priests got that. IIRC, the core books had somewhere between 10 and 20 spheres, with some more being added in sourcebooks (particularly Tome of Magic, which added some really esoteric ones).
Dark Sun then altered this system further, because Dark Sun didn't have any gods - instead, priestly magic came from the elements (sometimes taking a detour through an intermediary). So Dark Sun condensed the sphere system into five spheres: the four elements for magic specific to that element, and Cosmos for pretty much everything else. Dark Sun also had three priestly classes. The first was the Cleric which made a pact with the elements or elemental lords directly, and had access to spells of the chosen element as well as low-level Cosmos spells. The second was the Druid, which made a pact with a Spirit of the Land to protect a particular region (though they could roam free until about 8th level before they had to spend much of their time at home). The druid had full access to Cosmos and an elemental sphere appropriate to the region, and possibly low-level access to a second element if appropriate (a druid whose homeland is a hot spring would probably have full access to Water and limited access to Fire). Finally, the Templar worshipped and served a Sorcerer-King, and they got full access to the whole priest spell list: both Cosmos, and all four elements. They also got a number of civic abilities as they advanced in levels, giving them the ability to command greater power in the bureaucracy of their city-state - accusing and passing judgment on slaves, freemen, and nobles, and requisitioning troops and treasure.
Templars also used a slightly different spell progression list, where they advanced a little slower at low to medium levels (not even having spellcasting until level 2), but faster at high levels (when they caught the eye of their sorcerer-monarch themself).[/sblock]
All that said, I essentially see three ways of making Templars in 5e:
1. As a cleric domain, which would be the easy option. Domain spells and abilities would center on commanding people and stuff like that.
2. As its own class, which would mirror the abilities of the old one. They would essentially have access to the combined cleric and druid spell lists.
3. The more radical option, which I think was the path taken in 4th ed, would be to look at the templar's fluff instead of their crunch: they are people committing to pacts with vastly more powerful entities in exchange for magical power. That's what we normally call a Warlock. So make Sorcerer-Monarch a new patron for warlocks, and create some appropriate new invocations.