I had similar problem but with kittens ... two cats roaming around had 8 kittens and all of them used to just enter the engine bay .. i had to struggle alot to keep them away ... first two times we just scared them but it did not help ... so eventually i got a corrugated sheet roll and wrapped my car with it
.... the kittens were really small and i was afraid any day they can get in some belt wen i start the car ..... after couple of weeks the kittens were back again and this time they were a bit grown up .. they easily got inside the car jumping through tyres gap .. so this time i got a bigger corrugated roll and wrapped it 2/3 times around the car .. the gap between the tyres was also covered so eventually after 2-3 days they left ... that was just sharing my experience
definitely that cannot be done for rats as they would eat the paper .... i was recently looking at aliexpress if there is some device ( as i needed for my fruit tree as well to keep birds away ) ... so i found a device which generates some ultrasound waves ..( solar device or battery operated whichever suits u ) ..... there were positive reviews about it with one person saying he installed it in his backyard and his neighbor's dog no more come around his area now ... although i have not ordered it yet .. but something worth trying i believe ... maybe u can try that