I've done tremendous research on this issue and it has been reported that it is a hardware issue where there is a micro (hair line) fracture on the motherboard which results in components on the motherboard unable to send signals to one another (which I'm assuming is to do with the sound, also please correct me if I am wrong here). After a few factory resets and tonnes of restarting the phone (+ various other things), sometimes it would work until the next time the phone restarts and then it stops working again. I couldn't find this little fix anywhere so I thought I'd share it with the community.
Fix: First restart your Google Pixel phone and make sure you do the next step before the phone boots up. You need to apply pressure to the bottom, top and back of the phone. The way I did it was, use the palm of each of my hands to hold the bottom and top of the phone whilst using my fingers from both hands to press down on the back of the phone. Apply enough pressure (not a significant amount of pressure that you will permanently bend the phone, of course) through your palms and fingers to close that fracture until the phone boots up completely then you can release your hold.
Now your sound on your phone should be working until the next time it restarts. This fix has worked 100% of the time for me and I really do hope this helps others out there with the same issue as me.
Remember this is only a temporary fix, if possible you should get the phone replaced. I'm just sticking it out until the Google Pixel 4 comes out in a few months.