There are several PWM controlled cooling fans avaliable for the Raspberry Pis prior to the Pi 5, that are connected via the Pi's GPIO header. Examples are the Argon mini-fan, HighPi Pro Fan or ...