How does sonar locate an object in three dimensional space to output data for imaging?
Most underwater sonars that need to measure direction to a target use arrays of hydrophones.  When the outputs of the hydrophones are added, the resultant output exhibits a narrow directional response, called a beam,  which can be used to locate a target, usually only in 2 dimensions but 3 dimensions can also be done if the array extends in both the x and y dimensions.  If time delays are inserted in the hydrophone signals before they are added, the beam can be steered to allow finding targets in different directions. This approach has been used in naval sonars since World War I although the technology has advanced considerably.  For more details, I suggest searching on sonar beamforming.