I set most of my 5e playtests in a megacity setting that came into my head one day.
The basic premise is a city roughly the size of France and Spain combined (or about 1/8 of the land area of the USA). It's ancient and densely packed, running from a coastline of cliffs and sunken docks in the west to a continent-spanning desert in the east. The City has never had a central government - it's just too big. Legends tell of a couple of times when an individual was able to conquer enough of the city to name themselves Emperor, but none of these lasted past a couple of decades (usually falling to the squabbles of the generals once the original guiding force died).
Without any central power, the city is organised into districts - walled cities-within-the-City. There are tens of thousands of districts in the city, more than any single person could ever visit. Some districts band together into fiefdoms, with a few being quasi-nations in their own right with shared legal codes and culture. Each district is surrounded by a wall (for the older districts, a succession of overlapping walls as it expands). The walls themselves are magical and almost impossible to bring down.
Somewhere between a quarter and a third of the city is outside any surviving district, though - this area is called the Fill, consisting of slums, ruins and abandoned districts. Every few generations, a new domain arises from it... or sinks back into it. Some ancient domains have been sealed up magically, either as a result of magic or plague in the past; some parts have gone wild, with thick forests growing above and around urban decay.
The basic services of the city are provided by a number of powerful city-wide Guilds - one which maintains the major trade roads (and polices them; think lawful neutral paladin-nomads), one which maintains the sewers and aqueducts (as above, so below). One secretive group that manipulate the stone of the city walls (creating new walls around districts where needed, maintaining the old ones... and sealing up entire districts to halt the spread of disease and other contagions). One guild (really an alliance of many smaller guilds) that manages the flow of trade, concentrating mainly on staple foods (the most common of which is a long, starchy mushroom which can be grown on any stone surface with a little water and a simple magical ritual. When boiled, they have a bland, nutty flavour and look quite a lot like thick noodles. It makes terrible beer, which is considered traditional in most of the poorer parts of the City).
The guilds mostly recruit from the Fill, where they run schools and academies - and can better influence the loyalty of the students.
Obviously I have a good bit more setting detail in my notes, including a few bits and pieces on how such a large city can function (magic, obviously, but I have notes on the where and how), how it came to be, etc. It's been a fun setting to use - I've set a string of one and two session adventures in it, with the PCs all affiliated with a thieves guild (and the players told to generate any character they liked who had at least one feature that made them fit in the thieves guild (trickery domain for a cleric, illusion for a wizard, any race that's good at hiding, any background with thieves tools, stealth, deception, etc.