I am playing the excellent and wonderful Inkenfell, it is a RPG adventure that happen entirely in a school of magic, a uncontrollable magic force have been unleashed and the spirits of mundane items awaken and turn them into whimsical monsters. So you fight flowers, floor tiles, chairs, lanterns, books and other mundane items as you explore the school and uncover it secrets. This made me think that you could could play a magical school like a megadungeon or turn a megadungeon into a magical school.
You can craft your own megadungeon school or, in the spirit of my post about playing the orcs moms in the classic B2 Keep of the Borderlands module, you could hack a megadungeon to turn it into a gigantic school and play characters who study there.
If you craft your own megadungeon school of magic it could be fun to use the Ikenfell formula: you craft a gigantic school and you add a ton of secret areas, then you unleash a magical force in it. At the beginning of the campaign the school is your "ordinary" whimsical school of magic, the players can explore it freely, only expecting danger in specific mysterious areas. But once they gain a level or two you escalate things by unleashing a wild magical force that turn all the school areas into dangerous ones. That magical force could be enchanting people, animals and items, awakening spirits or opening portals to import monsters. The end goal of the campaign would probably be to seal that magical force and to make the school relatively safe again. The main advantage of this formula is that the player can familiarize themselves with the school before it become dangerous.
But if you feel like hacking, to create your school, you could take your favorite megadungeon and turn some of it rooms into school's facilities like classrooms, cafeteria, dormitory, lecture hall, library, courtyard, headmistress office, etc... And turn some of it monsters or occupants into teachers, librarians and the ground keeper. The big difference is that instead of starting with a safe school you start with a dangerous one. Maybe the megadungeon school was once safe and have only recently become unsafe. The campaign goal could still be to make the school safe again or it could be to prevent a dangerous force from awakening and making things even worse. Or you can simply play in sandbox mode and see what kind of goals will emerge. Even if the school is dangerous from the beginning I would assign some areas of the mega dungeon as no or low encounters zones. These warded zones could grow or shrink depending of the characters actions.
As for the characters themselves? They could all play young magic users but it would be more interesting to have a variety of classes or archetypes. Maybe a class less system like Macchiato Monsters could be a better fit to run that kind of campaign. But then again it could be somekind of school for adventurers that teach fighting, thievery, thaumaturgy and wizardry.
Let try to turn a dungeon room into a class room, I present you Barrowmaze High, School of Necromancy.
Room 103 (original text)
A Runic Golem (1) appears as a large pile of runic tablets in the northwest corner of the room. It will flicker to life with magical energy when the PCs proceed into the crypt.
A large elaborate mirror on a pedestal is positioned near the southern wall of this room surrounded by burial alcoves. Five feet in from the mirror is a bottomless pit. Anyone vain enough stand in front of the mirror will fall in.
Burial Alcoves: hexagonal, disturbed remains. Content: 87ep, Sapphire (75gp) and a Tome of Clear Thought.
The Runic Golem is clearly a teacher and is teaching magical runes and writing. The mirror work like a black board and is sometimes used as a test. Falling into the bottomless pit take you back to the study or detention room. The burial alcoves contain the remain of past students, you can cast "speak with dead" to get help for your assignment or to gossip. The one with the Sapphire probably have a sidequest. The Tome of Clear Thought can be borrowed by asking the teacher.