Yes using a surge protector with your generator will help to protect your electronics from damage due to the generator fluctuating in voltage due to surging up and down especially when it runs out of gasoline.
An inverter generator will work even better at protecting electronics from surges in power however if you have a regular generator that is not an inverter generator.
Then you can use a surge protector with a generator just like you would use a surge protector at home to protect your appliances and electronics from surges and fluctuations in voltage.
I use a surge protector all the time with my TV and other electronics at home with my regular mains power and with my generator to protect my electronics.