Here are the results of my testing a variety of weapons against megabeasts. In all cases, dwarves were grandmasters in weapon, fighter, shield user, armor user and dodge and megabeasts had no (added) skills (most of them have high natural skills though). The dwarves were given full plate armor (helm, breastplate, mail shirt, greaves, gauntlets and high boots), a weapon and a shield. This time I placed the dwaves and beasts 6 tiles apart, like so:
--------
|D++++B|
--------
Where 'D' is the dwarf and 'B' is the megabeast. 1152 Dwarves were placed first, followed by 1152 of the chosen megabeast. I did one round where weapon and armor were both steel:
steel spear 475 hydra 525
steel sword 344 hydra 656
steel axe 328 hydra 672
steel whip 207 hydra 793
steel hammer 19 hydra 981
steel mace 0 hydra 1000
steel scourge 0 hydra 1000
steel spear 771 dragon 229
steel whip 717 dragon 283
steel sword 677 dragon 323
steel scourge 666 dragon 334
steel hammer 650 dragon 350
steel axe 572 dragon 428
steel mace 563 dragon 437
steel sword 935 colossus 65
steel axe 877 colossus 123
steel spear 866 colossus 134
steel hammer 855 colossus 145
steel scourge 835 colossus 165
steel whip 822 colossus 178
steel mace 595 colossus 405
steel spear 991 roc 9
steel sword 968 roc 32
steel whip 965 roc 35
steel scourge 959 roc 41
steel hammer 945 roc 55
steel axe 900 roc 100
steel mace 807 roc 193
steel spear 996 minotaur 4
steel scourge 995 minotaur 5
steel sword 995 minotaur 5
steel axe 986 minotaur 14
steel whip 979 minotaur 21
steel hammer 975 minotaur 25
steel mace 879 minotaur 121
steel spear 1000 giant 0
steel scourge 999 giant 1
steel sword 999 giant 1
steel whip 999 giant 1
steel axe 997 giant 3
steel hammer 995 giant 5
steel mace 982 giant 18
In this case, spears are a pretty clear overall winner. They are the best against all creatures except bronze colossus, where they still do quite well, and they are by far the best against the hydra, which is easily the most deadly megabeast. Axes and swords are probably tied for second. Hammers, whips and scourges did well against most creatures, but were very poor against hydras (I think they get most kills by smashing brains, and having to do that 7 times is rather hard). Maces are the worst against every creature tested.
In the case of adamantine weapons and armor, the slashing weapons are better:
adamantine axe 987 hydra 13
adamantine sword 952 hydra 48
adamantine spear 815 hydra 185
adamantine spear 821 dragon 179
adamantine sword 778 dragon 222
adamantine axe 707 dragon 293
adamantine axe 996 colossus 4
adamantine sword 979 colossus 21
adamantine spear 858 colossus 142
adamantine spear 995 roc 5
adamantine sword 988 roc 12
adamantine axe 978 roc 22
adamantine sword 1000 minotaur 0
adamantine spear 998 minotaur 2
adamantine axe 996 minotaur 4
adamantine spear 1000 giant 0
adamantine sword 1000 giant 0
adamantine axe 997 giant 3
When made out of magical metal that cuts through anything, the large contact area and penetration depth of axes and swords becomes much more beneficial. Spears still do quite well, but all three edged weapons are fairly even overall, rather than spears have a clear advantage as is the case with steel.
I didn't run adamantine blunt weapons or whips as they of course will work much less well when made out of adamantine. It is also not clear how much of the benefit of adamantine comes from the armor, and how much from the weapon. I will try to run again with steel armor and addy weapons to sort this out.
In summary, spears, axes, and swords all did very well against all creatures. Hammers are also great weapons (especially considering they perform just as well when made of copper or silver), but if you get a hydra you will need something else.
Whips and scourges are good, but several of the native weapons are better, so my current testing does not justify using the low-quality whips/scourges you can get off invaders. If I get a chance, I will test whips against "goblin invaders", however I don't expect them to have a large advantage. They clearly are the best weapon against full steel/adamantine plate armor (i.e. your dwarves) but invaders are poorly armored enough that I don't think their amazing armor penetration will matter that much.
Also, keep in mind that all tests were run with dwarves that had grandmaster in all relevant skills. If I ran with low skilled dwarves, I'm sure they would be slaughtered by the beasts. Given that most weapons did pretty well, this again confirms that training and good armor are much more important then which of the native weapons you choose for your dwarves.
Edit: One other note - the dragons were much more deadly than in my previous tests. This is because they started further from the dwarves, and had more chance to breath fire. I confirmed that at least a large fraction of dwarven losses were due to being roasted. This also explains why dragons are the most deadly against adamantine armored dwarves - armor doesn't protect you from fire...