Ships have value even with with bullet holes in them.
Even if a relatively large amount of damage is inflicted on the ship a substantial part of the cargo will be intact, esp. if fire is directed at the superstructure rather than the hull.
The problem is not intact cargo, but finding customers.
Also, if the pirates actually do shoot hell out of a merchant ship at long range, how many other merchants are going to continue resisting?
My money is on private security forces, the Indian Navy, and others on the good side from countries that don't care about a few dead pirates. Financially, the pirates can't just shoot up a ship at long range. A cargo ship can take a whole lot of damage compared with the little speed boats they use for interceptions, or even with the pirate mother ships. Unless the pirates are using weapons that could destroy the cargo, the good guys get to shoot back, and it doesn't take many RPG hits to win against a pirate boat. By the time the pirates know they are in a shooting match, they will be dead, if we sink them instead of trying to make arrests.