Some component that is moving. The movement produces the noise. A great technician will know to SHELLAC any and all coils on the main circuit board to reduce that noise. As to the battery, if it is over 2 years old or holds a 15 minute or less charge that battery could be over taxing the power supply and if you leave that battery in the usual result is a dead board or wall charger. Fix (for the battery issue) is usually the new battery. If it's worth it or not is up to you.
But the point is that an old battery can damage the main board or have folk complain about laptops eating chargers. Now you know.
A workaround can be -> Leave out the battery.
My laptop is 6 year-old (Hp pavillion zt3019ea) and for few weeks now, has started to make this high pitched noise (like a mosquito!) only when connected to the charger.
I replaced the charger with a new one.Same thing. Then that new charger (8 days-old) died yesterday.
I thought I needed to get a new battery but at the same time is it really worth it for a 6 year-old laptop? (the hard drive has been replaced in March)
Thanks for your help!