You can keep your car in a Chapter 7 bankruptcy by one of the following ways:
1. If you can exempt (protect from creditors) the rest of the value of your car, you can keep it. California has a "wildcard" exemption of approximately $23,000 if you don't need to exempt equity in your home (because you either don't own a home or don't have any equity in it). You can use that $23,000 to exempt anything you own that isn't exempted some other way, like the additional exemption amount you need for your car.
For more details about California exemptions available to keep you car, see this prior article.
2. However, if you've used all of your available exemptions to protect other things you own, or you don't get the California wildcard exemption because you need a large exemption for the equity in your home, then you need to do some pre-bankruptcy planning.
If you have a legitimate need to get a new car, for example because yours has high mileage, no remaining warranty, and you won't be able to get a loan to replace it after you file bankruptcy, then you could trade in your car for a new one for which you would owe more than the new car is worth on the resale market. You would then have no equity in your car and therefore there would be nothing available for your creditors from selling your car. Therefore you could keep that new car in a Chapter 7 bankruptcy.
I'm reminded of the adage "Don't try this at home" about pre-bankruptcy planning such as described above. Please consult with a qualified bankruptcy attorney in your area before you do something like this.