In most states it is legal to sleep overnight at a rest area.
The rest area is designed for travelers to stop and rest and that can mean resting for a few hours or less or resting overnight.
Most rest areas limit people to around 10 to 12 hours of stay time before they must move on or be ticketed or told to move on.
I have slept in rest areas overnight when on long distance drives and slept just fine in the backseat of my car.
I never had any problems and never noticed any signs prohibiting overnight parking.
There may be some states that do not allow overnight parking and if so then there will be signs saying so.