The weapon ought to be fairly useless even against a target in the upper fringes of an atmosphere, if it really depended on a physical medium to carry longitudal waves.
However, as said, the sonic effect could be created at the target, rather than at the muzzle of the gun. We don't get to see any sort of a beam, sonic or otherwise, between the muzzle of a sonic handgun and its target, after all...
The same concept extends to Naval vessels and aircraft...
It didn't hold true for WWI and previous naval vessels, though, as those had a confusing collection of ranged weapons, each with a characteristic range. The best tactic was to close in to the effective range of the shortest-ranged weapon, so that the broadside would be maximally devastating.
In Trek battles, we could justify the melee tactics by saying that different types and sizes of starship have different effective ranges for their phasers. Thus, it's always best to close in to the most effective range of the secondary guns of a
Miranda, rather than stand off at the maximum range of the primary phasers of a
Galaxy, because the side that pours out the most fire is the one that's going to win.
Long range battles would become the favored tactic if the belligerents decided to standardize on one "caliber" of weapon, and if simultaneously the ships became too slow to be capable of freely closing in on the effective range of lesser weapons while under fire from the heavy guns. If two WWII battleships could open fire at 20 kilometers, but then move to within 200 meters in a matter of seconds, they would...
Timo Saloniemi