How to calculate size of filter capacitor for microcontroller that has changing loads on its 5V supply
Here is a first order calculation, ignoring cap ESR and other secondary effects. And assuming that your switching regulator is already chosen, and it is a budget off-the-shelf module. If you are doing a rigorous design from scratch, use Sunnyskyguy's answer.

\$
v = \frac 1 C \int i dt
\$

If i is a step from one constant current to another, we can simplify:

\$
\Delta V = \frac{I_{step} \Delta T}{C}
\$

Solving for C:

\$
C = \frac{I_{step} \Delta T}{\Delta V}
\$

I is the current step, delta V is the allowable voltage sag. Delta T is the regulator recovery time from a step current change, i.e. how long the cap needs to hold-up the voltage until the regulator closed-loop recovers.

Example: I = 1.5 A, delta V = 0.5 V, delta T = 1 mS

The regulator dynamic recovery time is usually not going to be included in a budget regulator data sheet. And if it is, it may be specified another way. 1 mS is a wild guess, you need to measure it by applying a step current change and looking at the voltage with a scope.

C = 1.5 * 0.001 / 0.5 = 3000 uF

A Rubycon YXJ 3300 uF, 16 V, has an impedance of 0.032 ohms, this is small, but not quite negligible for this application. 1.5 A * 0.032 ohms will add another 48 mV to the sag.

And remember, this is an approximation, we don't know what is inside the switching regulator, it already has capacitance included, most likely small compared to 3300 uF if it is a modern high frequency converter.