Running either a portable generator or an RV generator while driving down the road is legal and there's nothing wrong with running the generator while going down the road.
When you're going down the road you're vehicles engine is running so there's no difference in running a portable generator or an RV generator while driving down the road.
When I pull my travel trailer camper I put a portable generator in the back of my truck and let it run to supply power to the mini fridge in the travel trailer to keep foods cold and it also charges the batteries back up when going down the road.
Although I don't leave the generator running all the time but I can do so if needed.
I just need to run the generator when I first get going down the road to get the food cold enough and then I shut the generator off for a few hours and let the refrigerator just keep the food cold.
Then after those few hours I start the generator up again and let it run the refrigerator again.
A lot of people also run their RV generators when going down the road to supply electric power to the RV for the air conditioner and to power the TV and other electronics and it's okay to do so.