How to calculate size of capacitor for microcontroller that has changing loads on its 5V supply
C1 should be large and close to the motor load or at least close to the MOSFET.
In this way, the current drawn by the motor will be supplied by the large capacitor C1.
In your calculations use the Ton of the duty cycle instead of the frequency.
It's not quite correct using the frequency because your motor draws current during Ton.
I = C * (dV / dt)

once expanded:
C = (I * Ton) / ΔV

That will increase the value of C1 with respect to your calculations.
After calculating the value of C1, I suggest you to increase it by at least 30%.

I also suggest you to use an Aluminum electrolytic capacitor type.
Pick one that stands a maximum voltage value of at least 16 Volt: the higher the better in terms of filtering.
The best manufacturers are:
Panasonic, United Chemicon, Rubycon, Vishay, Epcos, Kemet.
https://www.digikey.com/short/3qmpwd3w?s=N4IgjCBcpgnAHLKoDGUBmBDANgZwKYA0IA9lANogAMIAusQA4AuUIAykwE4CWAdgOYgAvsQC0EaCDSQseIqQogALLACsIYioDMG8DWJgwiXaoBs64gCYqZk6ZNKIxAOxG6Qj0A