I have a MacBook Pro (13-inch, 2017, Two Thunderbolt 3 ports), it happened twice this week now. I have a dongle with HDMI attached while plugging in my charging cable. My sound was muted.
The noise is uncomfortable and it gave me goosebumps. It's like two pieces of thin metallic plates were scratching each other at high speed. The screech was horrible. I'm not sure if the sound came from the speakers or the machine.
I found someone who've experienced this too. -> Loud noise charging Macbook Pro USB-C