legal? yes. safe? well....
many states do have restrictions on riding in "cargo areas" (I haven't found any instances where installing a TC in the truck bed changes the definition of this area) but some, e.g. Nevada, make allowances for vehicles using camper shells or cap.
Interestingly, in New York, you cannot allow passengers to travel in a towed 5th wheel but you can allow them to travel in a truck camper. Here's a quick link for a state-by-state look:
http://www.iihs.org/laws/cargoareas.aspx
side note: truthfully, I can say that the only time I've ever looked in the rearview in my class C and actually noted that everyone was seatbelted in was traveling through Muddy Gap in Wyoming - the wind was downright scary. usually there's a lot of wandering about back there...