Nowadays, I'd recommend something heavy and scoped in the rifle department. Since the ubiquitous RPG's have the capability of making mincemeat out of a yacht within range, one might want to counter them at long distance.
As far as the paperwork goes, it varies from place to place ... but "Don't ask ... Don't Tell" seemed to work in many places, and wasn't onerous in others.
It’s extremely unusual on the ocean for it to be calm enough to use a scope, unless it’s maybe under 3 power. You cannot get a steady rest, such a thing does not exist on a boat on the ocean, so you must fire off-hand, from a sitting position usually. With a scope of 4X or more, you will not be able to hold a target.
Actually, the best way (in daytime) to aim is to spot your splashes. Even500+ yards out, you see your splashes easily unless it’s really rough out, and then you don’t need to worry about pirates in speedboats.
A semi-auto with lots of bullets is the ticket, in either 5.56 or 7.62. The idea is to just put a ton of splashes in the water around the pirates to help them remember an urgent appointment elsewhere. They are not Marines storming Tarawa, and have no interest in testing your accuracy with their chests.
If you hit them great, but the idea is to deter them at long range. If you are taken by surprise and you find them upon you at close distance, typically right up your stern, then again a semi is useful. Or a shotgun.
BTW, a S.S. Ruger Mini 14 was one of the guns now on the sea bottom off of Hualtuco Mexico.