You’d need to write a few functions to control speed with PWM and have something like a hall sensor to record your RPMs to adjust the speed.
Just be sure to power the fan with an external power supply(look up how to connect a 12v motor to an arduino).
Anyone have problems with this if using a Leonardo or Micro/Pro Micro?
Had to rewrite the serial class to make it work.