It sounds like you have a SMC issue. What happens is SMC will ramp up the fan's speed as well as lower the CPU's clocking to prevent the system from damage.
I would see what the onboard diagnostic tells us. Restart your system and press the ***D*** key to enter, let us know what the error codes are.
Reference: [https://support.apple.com/en-us/HT201255|Mac startup key combinations]
Depending on the macOS release you have installed you might encounter it won't work, thank Apple from messing it up!
If that happens we need to see what [https://www.tunabellysoftware.com/tgpro/|TG Pro] tells us the free version is a good start but the full version does offer some diagnostic functions. Take a snapshot of the apps main window, making sure to get all of the sensors and fan info into the snapshot and post it here for us to see [guide|21499]