Can a necromancer raise the dead if they have a visual line of sight on the corpse, or do they need to be able to attack it, such as through fortifications?
If so, have the necromancer patrol around the top of the pit, just so he can see down into the pit. While you can't make him patrol, random wanderings will have the same effect over time, so all corners of the pit will be visible eventually. This means undead everywhere will be raised.
The necromancer can only raise things in the pit itself, so any zombies that escape can be quickly cut down through a combination of weapon traps and dwarven steel, and then the lifeless corpses can be chucked into the pit from above, where the necromancer can then raise the corpse yet again.
Try something like this on for size:
Z+1, pit necromancer into narrow walkway with fortifications overlooking the bottom of the pit
XXXXXXXXXXXXXXXXXXX
X.................X
X.FFFFFFFFFFFFFFF.X
X.F F.X
X.F F.X
X.F F.X
X.F F.X
X.F F.X
X.F F.X
X.FFFFFFFFFFFFFFF.X
X.................X
XXXXXXXXXXXXXXXXXXX
Z, pit bottom, zoned corpse/refuse stockpile. Artifact grade armor stand or weapon rack in middle of pit zoned as barracks. Building destroyers cannot topple artifact grade armor stands or weapon racks. Assign squad(s) for training as you see fit.
XXXXXXXXXXXXXXXXXXX
X.................X
X.................X
X.................X
X.................XXXXX
X.......A.........D.... <==door and passageway to fort
X.................XXXXX
X.................X
X.................X
X.................X
XXXXXXXXXXXXXXXXXXX
Downside to this design is that markdwarves won't work, because they will kill the necromancer, but if you just adjust the how the fortifications are laid you, you could easily allow both the necromancer and marksdwarves to see into the pit without being able to see each other.