PWMing the fan is likely to mess up the RPM output anyway, as the internal tacho sensor needs power to function and unless the fan is designed to be PWMed with a diode and separate reservoir capacitor to maintain power to the sensor, it wont get any during the PWM off period.
You could try a high side P-MOSFET to PWM the fan supply rather than its ground, with a level shifter or even a gate driver IC to turn your logic level PWM input into what's needed to drive a MOSFET gate fast enough and hard enough for 25KHz PWM. Do't forget an anti-parallel diode across the fan in case it as a load has a significant inductive component.
However if that doesn't give you a clean RPM signal, you'll probably need to go to a buck converter controlled by your MCU to provide the fan with a variable voltage continuous DC supply. The easy way to do that is to take a 3A 'LM2596' buck module off Amazon, Ebay or the usual Chinese sites and inject a current to the feedback pin of the chip to offset the output voltage its sensing. That's pretty easy to do - just RC low pass filter (with a couple of stages and a time constant a couple of orders of magnitude greater than the PWM period) your MCU's PWM output, and couple it to the feedback pin through a resistor. When the PWM is at a duty cycle that would give 1.23V out without the coupling resistor, it will have no effect on the set output voltage of the LM2596 module. Raise it and it will depress the voltage out, and lower it and it will increase it, by an amount determined by the coupling resistance (including the resistors in the low pass filter) and the resistance of the existing feedback network. You may also want to lift the LM2596i nON/OFF pin so your MCU can control that directly, rather than trying to drive the output voltage to zero to switch the fan off.
N.B. Most cheap LM2596 buck converter modules have fake chips that work down around 50-60KHz rather than the 150KHz of a genuine one or better quality clone. The problem with that is the coil and capacitors are usually sized as-if it was actually going to run at 150KHz so at best a nominally 3A module will be good for 1A. In practice other cost-saving will have been made and you can only really expect 0.5A reliably, so don't try to put multiple 0.5A fans on the same module.