you can dig out a maze and line it with cage traps like this:
the only tricky part is that necromancers tend to run if about half their zombies are caged, normally this wouldnt be a problem because the maze is sealed by a retracting bridge linked to a lever, which you can use to seal them in (so using this method you'll probly need to wait until the next necromancer siege before you can get one). Then you can unforbid one of the doors leading from the maze into your fort so that they try to escape by going further down the maze and out through your fort.
Note: that its suggested that you forbid the entire maze using area-forbid when its in use, and use a military alert burrow that does not include the maze to prevent civilians from running to the inside of the maze.
all 3 doors in this design are non-pet passable and a sacrificial pet is penned behind them so that the undead and other sieges will be lured into the maze.
this design works against undead without fortifications or water pumps, but i suggest replacing some walls with linked raising bridges at some time so that you can clean it out faster. Fortifications and water pumps are for goblin sieges and ambushes, where the invaders do not path independently and get stuck in the maze if their leader is caged. You can then drown them or send elite marksdwarves.