I have relay controlled by BC547 transistor powered by 24V Zener regulator. The transistor is switched by a microcontroller which is powered by a 5V linear regulator. The linear regulator receives input from the 24V from Zener regulator. At the instant when relay is switched, linear regulator 5V output fluctuates between around 1V min to 7.8V max for about 20nS.This causes microcontroller to reset(but not at every instant).
This looks like a step load with a nonlinear high Q with a resonant frequency of 2.5 cycles in 5 ns or 500MHz ! Knowing the RLC equivalent circuit that would create this step response ! How would you decouple this back EMF signal from interfering with the output impedance of your supply by some filter design converting voltage to current and attenuating the reverse transfer function by impedance ratios and Q control? Series RC? Lower output impedance of regulator at 500MHz?
You can design this by using this method of filter analysis. Identify all the variables, DCR, Rs diode, Vf diode, L, C , ESR, Zout (f) , V+ in an equivalent circuit with a current step function or adjust the slew rate of the step by design....
But beware this 0.5GHz BW of probing requires special attention to ground inductance of probe, so the best measurement is a 50 ohm source and 50 Ohm Terminated , AC coupled coax connection to DSO on 1:1 with high quality coax. This is unusually high BW but appears to be a dry contact switch. So use V+> C+50 series>coax>50 shunt>DSO 1:1 Also beware of shared currents on gnd noise and layout LC coupling crosstalk.
Also ensure DSO scale is correct and not “us” instead of ns.
Basically you need to slow down the turn-on and -off of the driver transistor so that it doesn't energize the high frequency parasitic RLC circuit. Likely you can do this by putting a resistor in series with the base to limit the base current (you should already have had a resistor there), and/or putting a capacitor in parallel with the base-emitter -- perhaps 1 nF.
In addition, add better decoupling capacitance at the output of your linear regulator, and/or at the VDD pins of the MCU.