The Simplest Option - Passive Lock Strap
By far the simplest and easiest way to do this is to use a "trunk lock strap" or "passive lock strap". Searching in Google for either of those phases should turn up suitable products.
The idea with these is that they are a flexible cable that you loop around your bike and then close a thicker stubbed end inside your vehicle either in your trunk if you use a rear rack, or inside a passenger door if you use a roof rack.
You should note that no product is completely theft-proof, and you will ideally want to use more than one locking/security mechanism. At a minimum, if leaving the bike on the rack, I would remove the front tire and put it in the car as well as using this strap. That way they can't just cut the strap and ride away with the bike.
More Complicated - Tow Loop
A more complicated and likely far more expensive option is to look into the installation of an external Tow Loop. Many modern cars that are not equipped with a towing package, still have some kind of loop or bracket either directly under the bumper, or beneath some removable cover in the bumper. You can have an externally accessible tow loop retrofitted to the car and then you could lock the bike with a cable through that loop.
Google your vehicle make and model and add the words "tow hooks" or "tow points" for ideas, or talk to a qualified auto mechanic/dealer.