Simply put, a Theocracy is any society in which the The Church is the government. Often the laws of a theocracy are based off religious law, or claims that God (or Gods) is the supreme ruler of their state. This is especially prevalent in pre-modern settings.
It's common to have an official state religion, but this doesn't necessarily equate to a theocracy or even an especially religious country. For example, in England the head of state (the monarch) is also the head of the Church, bringing an overtly religious aspect into the governmental system, but England and the UK in terms of population are much less religious than nearby, officially secular Ireland and France.
Note that true theocracies, where secular government is virtually non-existent, are fairly rare. Most often the Church will simply have a lot of secular power and sometimes a parallel government: authority over religious/moral laws, it's own bureaucracy, it's own army, etc.
Compare Church Militant, where the clergy is Badass, but not necessarily the rulers of a country. A Corrupt Church is often the head of a Theocracy, but not always.
Examples of this trope in media:
open/close all folders
Anime and Manga
Prussia from Axis Powers Hetalia was once the child embodiment of The Teutonic Knights, who were in real life a militant Catholic monastic order who happened to run their own realm...which would serve as the basis of their Prussian descendants. Although it's subverted in that the Nation seems to shed at least most of his piety once he drops the knight act.
Comic Books
In the DC Comics miniseries World of Krypton it's shown how the government of Krypton came to be science based. There were three competing factions: one for science, one for democracy, and one for a Theocracy. They decided to let the Kryptonian gods decide. One representative from each faction went out into a thunderstorm with a rod; whichever one didn't get hit by a bolt would be the chosen. Science won after theocracy and democracy's reps each got hit. In The Stinger of the story the scientist admitted to a time-travelling Kal-El that he had used a non-ferrous metal in making his rod. He didn't consider it cheating since the gods told him to do so - or so he claimed.
Literature
The Lands of Holy Order the Arkanar Kingdom in the ending in Hard to Be a God.
In Donald Kingsbury's Courtship Rite, the overclans are all priest clans, ruling by religious right. Basically, the whole world is a theocracy, although given the harsh conditions of survival on Geta, a fairly pragmatic and not-very-hierarchical one.
David Eddings has two examples in The Elenium. The first is the city of Chyrellos which is more or less an expy of the real life Vatican example below, an independent city state ruled by the head of the church and run by church officials of a much larger religion. And despite not having a distinct homeland and only a single city to call their own, the Styrics probably also count since their highest body, capable of making decisions for all Styrics regardless of where they reside, is composed of the High Priests and Priestesses of the Younger Gods of Styricum.
The Temple Lands in David Weber's Safehold series is one disguised by a very flimsy legal fiction. Technically they are ruled by the Knights of the Temple Lands but every single member of that groups happens to be a member of the church hierarchy and church groups are used to enforce their rule, so it is a de facto if not de jure Theocracy.
In Elantris, the Fjordell Empire is a theocracy controlled by Shu-Dereth and its leader Wyrn Wulfden IV is both High Priest and Emperor, considered the only living human who has a direct connection to Jaddeth.
Warbreaker has a less antagonist version. Hallandren is ruled by the Court of Gods and their priests; though there's certainly corruption to go around and the gods themselves can be rather out of touch with the world, they're not really any better or worse than most governments. The God King himself is actually quite a decent guy, if a powerless figurehead, and his High Priest, though he initially appears to be the Big Bad is actually a Well-Intentioned Extremist opposed to the real villains.
Inverted in The Stormlight Archive. Vorinism is the dominant religion of the nations the protagonists come from, but its priests (called ardents) have next to no political power and are kept staunchly under the thumb of the aristocracy and are even denied personal property to make sure they don't try to extend their influence beyond spiritual matters. This is because the Vorin nations were a theocracy (called the Hierocracy) centuries ago, and it was supposedly extremely corrupt- when the nobles seized power back, they wanted to make sure the Hierocracy would never return.
In Parable of the Talents, the U.S. is on its way to becoming a theocracy. The Glorious Leader, Jarrett, is a member of the Christian America sect which blames all non-Christian "heathens" (and sometimes Christians of other denominations) for America's problems. They have significant power over the country, with their own army and POW camps.
The ginormous Imperium of Man is very much a theocracy, given that they have a Physical God as its former leader. However, ever since a prominent Ecclesiarchy member went mad and tried to form his own Imperium within the Imperium, the Ecclesiarchy is no longer allowed to keep "men under arms". Hence theSistersofBattle. Also, their priests accompany the Imperial Guard into battle wielding inspiring speeches and eight-foot-long chainswords.
Similarly, on the Chaos side the leaders tend to be those who the gods most favor. However, they aren't really priests, as the Chaos gods would much rather their followers kill loyalists and aliens instead of holding masses.
The Lizardmen of Warhammer are led by their Skink priests, who interpret the wills of their gods.
The Theocracy of the Pale in the Greyhawk setting. In the Living Greyhawk campaign, the real-world region assigned to it was Utah.
Thrane of Eberron, ruled by the Church of the Silver Flame.
Until the Time of Troubles, Mulhorand and Unther in the Forgotten Realms setting were ruled directly by avatars of the Mulhorandi and Untheric pantheons (by Word Of God, the actual Egyptian and Babylonian gods), and the countries functioned as theocracies with the priesthood also forming the bureaucracy. Mulhorand continued to be one after the avatars were allowed to return to their home plane, but Unther collapsed after all its gods were killed.
Morrowind in The Elder Scrolls was once ruled directly by its three Physical Gods, and even though the games are set in a time after The Empire forced a secular government on them, they still maintain a lot of power. By the end of The Elder Scrolls III Morrowind, a minimum of two of the Tribunal are dead—Sotha Sil by Almalexia's hand, and Almalexia and potentially Vivec by the player's—and regardless of whether you killed him, Vivec disappears from his city in the interim between Morrowind and Oblivion.
The Paranid Empire in the X-Universe are ruled by one Priest-Emperor Xaar, and each Paranid settlement or station by a priest-duke. Their (rather bizarre) religion permeates every aspect of Paranid life, making Holier Than Thou the species' hat.
For most of the humans in Spira, the world of Final Fantasy X, the only government is also the only (apparent) religious institution, the Church of Yevon.
Fire Emblem: Awakening features the Halidom ("Holy Kingdom" in the Japanese version) of Ylisse, devoted to the worship of the Divine Dragon Naga, as well as a more sinister version in its neighbor Plegia, whose citizens worship the Fell DragonGrima.
In The Gamers Alliance, the Godslayer takes over the kingdom of Aison after the Cataclysm and gathers a group of followers, the Grey Cult, which begin ruling the country in the Godslayer's name with the High Prophet as the Godslayer's spokesman.
Real Life
The closest thing we have to a true theocracy in real life is Vatican City, which is ruled by The Roman Catholic Pope and has a government staffed by clerics.
Until the total unification of Italy in the 1870s, its predecessor the Papal States (at least in theory) served this role. How this exactly played out as well as its reputation depended on the time period, given how it's fostered both saintly figures and the likes of the Borgias.
The Islamic Republic of Iran is nominally a Muslim theocracy under the guidance of the Ayatollahs. In reality, it's a subject that's tad more complex. And very delicate.
A better example might be Afghanistan when it was under the control of the Taliban. They're such an infamous example that the word "Taliban" has entered the English lexicon as a negatively connotated term for anyone who seems to be in favor of a theocracy, especially an extremist one.
The Byzantine Empire is an odd example of sorts, in that the line between Church and State was very thin, with the Emperor having religious authority and influence rivaling the Patriarch of Constantinople.
The modern Israel is a borderline example. It defines itself as the Jewish State or "Hebrew State". Even though rabbis don't really have political power, there are several religious political parties and Judaism is clearly a central aspect, both in the country's identity and its international policies.
This has the wrinkle that Israel always defined itself both as a nation and as a religion, though which predominated varied. Having the idea of theocracy kicking around is inevitable. Most Zionists though were nationalists and emphasized the ethnic aspects.