single pin mode

If you want to run this in 'single pin mode' behind a logic level shifter you can connect the echo pin on the 3V3 side to the trigger GPIO via a 4KΩ:ish resistor. This works for a a classic MOSFET level shifter built out of two BSS138 and four 10KΩ resistors. Make sure that the esp GPIO reads low (input mode) when HC-SR04 echo pin is driven low. If it reads high the R2 resistor needs lower resistance.

Wiring echo & trigger together on the 5V side does not work with a classic mosfet level shifter.

Another working solution is a voltage divider (5V to 3.3V) between HC-SR04 echo and ground. Connect HC-SR04 trigger and esp GPIO to the middle of the divider.

other sensors

The arduino library newping supports a whole range of ultrasonic sensors: SR04, SRF05, SRF06, DYP-ME007 & Parallax PING™. This without making any special hardware considerations in the code. So this library should work with those sensors as well.