You can limit the max. frequency of the CPU per core, to avoid such behaviour. However, if you have a powerful CPU, then you need a powerful fan. If the fan is not up to the task, it has to go on 100% speed, on every spike to compensate for the higher power consumption, i.e. higher frequency, i.e. higher performance, i.e. higher heat output, as is mandated by physics.
When you are buying a fan, it usually has a guiding TDP value, that shows you how much power/performance/heat it is supposed to handle.
All that said, the whole point of such powerful CPU is, that it accomplishes tasks with more performance, i.e. finishing each task earlier, quicker or more efficiently. To accomplish this performance benefit, it has to use its full power, which results in the fans going up to the top.
Conclusively, you either have to downclock your CPU, which means that you do not use the full power of the device, which in turn means that the device is used inefficiently, as you are paying more for the device itself, as well as for the power consumption it creates, without using the benefits, or you provide a better fan, that is up to the task and ideally specifically made for powerful CPUs.
Of course, there are also sound proofing solutions, etc. but such things are way more complicated and demand much more effort for them to be effective. It’s not healthy for the CPU to have a weak CPU fan, either way. Letting PC components heat up too much over a very long period of time, may increase the damage they gather over the years, possibly leading to an earlier device fault, than usual.