Fluctuations of the spectrum in rotationally invariant random matrix ensembles