the sonar can only be used when the ships type (merchant/warship) appears on the notepad you can see next to hydrophone wheel. that happens when the range to target is under 7500 m. however, the max sonar range is limited to approx. 4000 m, IIRC, depending on the type and year.
however, even if the contact is close enough to use the sonar (within 4 km), you cannot ping it as long as it is in your "deaf" zone - directly behind you, from 170 to 190 degrees or rather from 160 to 220 depending on the hydrophone type and year. there is also the early war GHG hydrophone that has two "deaf" zones - directly behind you and directly in front of you. but I dont think this is your case as it must be already 1942 or 1943...