I haven't come across any naval battles so far but I haven't gone looking either. If I get one of those messages but I'm not anywhere near the action I stick to my original mission.
Sonar pings dangerous? With destroyers around you betcha! If you are trying to sneak in on a target and destroyers are around, using your sonar to ping a target is the equivalent of announcing "HERE I AM!!!" LOL. If you're hiding in a pitch black room and you know someone is also in the room (with a large baseball bat full of nails) looking for you in order to kill you, would you shout or make any unnecessary noise and give away your position even though they can't see you?

I don't think so.
If the merchants are alone however, using the sonar to ping a range from them, in my experience, does not cause them to react and can be used effectively and safely. Having said that, I wouldn't actively ping as a habit but only if necessary.