I have a herniated disc in my lower back (l5-s1). Is it safe to do spinning as exercise?

Depends. Spinning is an excellent, low impact activity. For patients with a herniated disk, it can be safe as long as it doesn't worsen symptoms.
Yes. Exercise, especially cardiovascular regimens are helpful although you may find sitting to bother your back so you may want to consider cross training if there is some aggravation of your pain spinning. 90% of disc herniations get better non operatively with a 5 % chance of a recurrence which is minimized by regular exercise.