How to set FrameBufferFillMode.Gradient2Color with python?

As far as I know, background styles are not related to viewports but they are related to displayModes.
But in your case, you can change the background style in displayMode of all your viewports.

import Rhino
for view in Rhino.RhinoDoc.ActiveDoc.Views:
    displayMode = view.ActiveViewport.DisplayMode
    displayMode.DisplayAttributes.FillMode = Rhino.Display.DisplayPipelineAttributes.FrameBufferFillMode.Gradient2Color
    Rhino.Display.DisplayModeDescription.UpdateDisplayMode(displayMode)