This post really needs to be subtitled "A Megadungeon Template." I say that because the Drow module series is the best example I can find of a TSR-published adventure that provides the sort of megadungeon I would want to run.
The D-series of modules are comprised of D1, D2 (Shrine of the Kuo-toa) and D3 (Vault of the Drow). That series of modules provides a variety of location-based adventures, while simultaneously giving the Dungeon Master a wealth of un-developed locations for future use.
Each hex of the above map represents one mile, and only the dark grey sliver, extending from the top-left to the bottom-right of the map, is developed in the D-series. The rest of the map, including the sunless sea in the top-right corner, is left for the Dungeon Master to develop.
The D-series starts where the G-series (Against the Giants) left off. Having defeated the Hill, Frost and Fire Giants, the players discover that all three giant races are being manipulated by the Drow, a race of evil subterranean elves.
The characters come into possession of a map, and using a rope-bridge and crane, the party crosses a river of lava in search of the lost city of the dark elves. As they make their descent towards the dark elf stronghold they encounter giant slugs and other enormous subterranean creatures.
There are three major encounter areas in D1, Descent Into the Depths of the Earth. The first is a Drow checkpoint, staffed by two separate Drow patrols.
The second encounter is a Mind Flayer outpost, representing an incursion into the realm of the Drow.
Finally, the party reaches a massive underground cavern, populated by Bugbears, Troglodytes, and Trolls, along with Drow, Purple Worms, a Lich, Gargoyles, and sundry other potential adversaries and allies.
Other than the first Drow outpost, there is no absolute requirement that the characters must participate in any of the encounters in this module. Nor must they defeat the Drow or any of the other denizens. In fact, there is an opportunity to win the trust of the dark elves by eliminating the Mind Flayer outpost. The players will likely encounter at least one drow caravan while plumbing the depths, and those encounters also provide opportunities for role-playing and negotiation.
Even the Lich, who occupies a side cavern within the major encounter site of this module, can be easily avoided: don't enter his lair to begin with.
I really like the form of adventure that the D-series represents. While it provides a destination-based adventure path, there is no particular requirement that the players pursue a specific goal as they seek that destination, nor does the module presume that every denizen encountered must be defeated. In addition, the module offers side passages that the DM can flesh out, to create a completely novel adventure. And then there is that tantalizing sunless sea, lurking up in the top-right corner of the map.
I like that there is a boundedness to the D-series of modules, while offering significant agency to the DM and the players. That, to me, is the hallmark of a good adventure product.