realtime software 90 degree phase shift a sinusoidal signal
If you have it in a buffer and have enough computing power, you can track it to quite significant accuracy using two DFT bins and the formulas shown here:


A Two Bin Solution


For minimum latency I would recommend a frame length near 2 and 1/2 cycles, though for a clean signal 1 and 1/2 cycles should also give good results.

As you do a series of sliding windows, this will generate a sequence of parameters.  A moving exponential average of the parameters should give you a good current value (when they are slowly varying) to use.  More sophisticated techniques are available.

Once you have the current parameters, you can reconstruct a signal with any phase lag and/or amplitude adjustment you want.

Or if you are tracking the phase value frame to frame, the most accurate fit is at the center of the frame ($t_f$ is at $n=N/2$).

$$ x(t) = A( t ) \cos( \Phi( t ) ) $$

Where $ \Phi( t ) $ is a (predictive) near linear function and $A( t_f )$ comes directly from the two bins solution.