I make it a habit never to send outmatched melee dwarves into combat. Full steel before you risk them: they are worth more than the results they can give you until they have the MAXIMUM chance of surviving, to continue making use of that time you spent training them. Also by the time they're Legendary in weapons skill, you'll have lots of masterwork armor and weaponry to make them ridiculously effective. Fully armored, High/Grand Master dwarves are absurdly deadly, and goblins run away fast. I'd say even 30 dwarves in iron/bronze armor, with Competent skill averages, could drive off 40-50 goblins. You'll lose a few, but if it's valuable to break the siege do so. Otherwise, let'em leave and keep training your death machines.
By the way, my trap systems are usually basic, but I once came up with a plan for a Colosseum type entrance.
It was going to be set in a three-z-high cavern, with marksdwarves stationed all over the top, lots of paths above a 20z chasm, some drawbridges etc to make pathing interesting, lots of ballistae covering the longer, straighter stretches of Khazad-Dum grade bridges, and also a Doberman bomb for fun. And the melee dwarf release was going to go next to a giant pit for !!FUN!! should anything dodge wrong.
Or you could use cage traps and bridges as stated above to isolate the enemy and pick them off. But cagetrapping 3 goblins and seeing the rest run is lame ... lol.