Generally speaking, an active sonar ping is an act of war. Most sub warfare is based around passive sonar and means. An active sonar ping is a signal that there are about to be fish in the water.
Of course, most of it is theory with little real world wartime practice. In general, an active ping is a solid way of getting accurate ranging, but you're guaranteed to see the board change rapidly - so… most sub warfare is just being really good at stalking each other with the world's most sensitive microphones.
Since surface ships are generally visible, there's only some effort put in making them quiet. Thermocline and seabed problems make sonar less useful for them in the first place, but they are generally supposed to keep down on active sonar. It is still considered an act of war, just subs don't take them seriously because of the limitations of surface sonar.