It's somewhat of a grey area, because you can be sued for anything at any time, regardless of whether the person launching a legal attack against you is correct or not. Even if they're not in the right, can you afford to hire an IP lawyer to defend you in court against such an attack?
So the question isn't "is this legal" (a black and white yes/no answer), it's "how risky is this" (a grey area answer).
Using real-world products within fiction has a very long precedent as a way to ground the fiction within the real world. Usage of a product in it's intended manner, in a way that doesn't imply endorsement by the product, or unfairly attribute flaws to the product, is legally allowed.
However, many games which have tried to do this have found themselves the target of lawsuits anyway. I'm not aware of any game that has actually gone to court to successfully argue that they have done no damage to the brands involved and are innocent -- in every case I've seen, the game developer has backed down and paid a settlement fee, or changed their game, etc...
The actual design (shapes, styles) of the cars is covered by copyright. Straight up copying those designs opens you up to legal attacks based around copyright infringement.
The names (brands, logos, etc too) of the cars are covered by trademark. Using them at all opens you up to legal attacks based around trademark infringement.
So, it actually can be legal if done carefully, but it's always extremely risky, especially if you don't have the money to fight for it in court...