Why is it that, on a morning of very dense fog, one can stand outside and hear noises from great distances?
The observation is misplaced slightly .. the significant factor is not fog, rather the conditions which often predispose to fog .. ie high pressure system .. clear, cold night ... negligible wind ... equals pronounced temperature inversion.
Two points are relevant ..
(a) temperature lapse rate
(b) variation of a0 with temperature
End result is that a sound wave ends up refracting back towards the ground .. rather than refracting towards the vertical.
Simple to see in a sketch .. start with an hemispherical pressure wave .. then consider the refraction due to small a0 variations along the wave ..