I see some ultrasonic sensors have legs with different length, such as below. Does it means they have polarity?
Are there any differences taking different leg as the signal pin?
As people have already indicated in the comments, from the perspective of the actual ultrasound signal (transmitted and/or received) it doesn't make any difference at all. But my intuition tells me -- and small features in the drawing seem to indicate -- that one of these terminals is probably tied to the outer shield.
Without an actual part number and/or datasheet we have no way to be certain. But what we know for sure is that this part has a shield, and the shield needs to be connected to something to be useful. If this is a 2-pin device, then yes it's a safe bet that one of these terminals is connected to shield and the other isn't, so yes polarity matters.
Other answer mention that it matter if transducer have shield, but it also matter if it doesnt. Difference is that when terminal one has higher (lower) voltage than terminal two then piezo element will flex outward (inward) or other way around. When you use one transducer it usually doesnt matter which way you use it, but if you want to use more of them in array it does matter that same voltage will result in same acoustic wave and not inverted one.