Two factors are involved. The most obvious is the time interval between when the sound was made and when it was heard. The other, less obvious factor is that the reflected sound will be Doppler shifted. The bat will hear the sound at a lower or higher frequency, depending on whether or not it is traveling away from or towards the insect. I don’t know if you want to get into the mathematics, but essentially, if the bat can determine how long it took for the sound to be reflected as well as how much the frequency has changed due to the Doppler effect, it can determine it’s distance from the insect.