You cant that is the whole issue it is
illegal for any non naval vessel to be armed in international waters every nation on earth agrees with this and it this way for logical reasons.
Do you know anyone with a captains license? They will tell you the same thing civilian ships can not be armed then comes the whole issue of different nations ports many of them ban all weapons at best you only have small arms like handguns and rifles(sort of) which makes you outgunned because the pirates have light machine guns like PKMs and they have RPGs you'd need the type of fire power that is not allowed to have a chance if you tried to fend them off with deadly force an M2 is not a legal weapon for a merchant vessel.
Have you ever fired an M2? Have you ever fired one on the high seas? I doubt that you have because if had you'd not say that they are so easy to use.It is a very loud weapon and I even saw other folks in the military be rather nervous when firing it the first few times. The M2 is too complex for a lay person to use with any effect hell they'd sit there all day trying to get it to fire after only cocking the thing once when you need to rack the handle twice I bet.No firearm is as simple as point and shoot to use with any effect.That may be true when the person is 3 feet away but not for a speed boat shooting at a person with no training being nervous and trying to hit a boat on the high seas.