While I haven't found a fix to this problem. I have figured a temporary workaround.
I checked the kexts that are loaded when sound is working and when it isn't. I figured that AudioAUUC.kext isn't loaded when sound is not working.
I checked whether it was because of lack of AppleHDA and AppleHDAController. However both of them are loaded in both cases.
With this information I added AudioAUUC in ForceKextsToLoad in config.plist.
Even though, it is not fixed, It loads more consistently (I might have to reboot once or twice).
Before this workaround getting audio to work was always pure luck.
However, I would like a permanent solution to this problem and not have to keep rebooting my system for the audio.
@xiaoM4095 do you have any solution? Or should I start a new thread in Laptop Support?
Thanks.