Freighters that ferry goods in the pirate-infested waters off the coast of Somalia have a new and unusual cargo: armed guards.

Shipping firms in the modern era have resisted packing heat even in areas where attacks are common. Their reasoning: A firefight leading to lawsuits, damaged goods or a sunken ship could cost hundreds of millions of dollars, a sum far exceeding the few million dollars in ransom that pirates usually demand.

But...