The area you will cover is a bit broad but there are generally rules that you can follow:

1.  If you see the [No Overnight Parking sign][1] that has an obvious meaning.
2.  There are plenty of roadside motels and camping grounds where you can park overnight and sleep.
3.  The municipalities may institute their own rules for overnight parking and sleeping in cars so when you enter one you should check for signs that may indicate possibility of overnight parking.
4.  If you need to sleep on a highway find a parking area rather then the side of the road.

Now for more details you should provide more exact places you will be visiting and routes you will be taking because between San Francisco and LA is about 400miles/650km on the shortest route and for example [Greater Los Angeles Area][2] is about 85000 Sq/km with about 18 million people and a large number of individual municipalities.  [San Francisco adds a bunch more][3]

[1]: http://www.myparkingsign.com/MPS/No-Overnight-Parking-Signs.aspx
[2]: https://en.wikipedia.org/wiki/Greater_Los_Angeles_Area
[3]: https://en.wikipedia.org/wiki/Greater_San_Francisco