An exterminator once told me rodents hate moth balls.
Yeah, except not sure how you keep the moth balls from rolling out.
Pouch them in cheesecloth and zip tie the pouches under the hood. Doesn't necessarily have to be in the hood. Could also stuff the holes with steel wool. I have done that with mouse holes then filled with expanding foam spray. They won't chew threw that combo.
I have heard and seen people doing the moth ball thing, and yes just like Dave described.
When not in use the truck if parked under a carport. It is not a daily driver and only driven sparingly other than started up every once in a while. I have 5 dogs on the otherside of the fence and cats that roam the area.
It would be good if you could get an idea what the critter is, here the main things are mice, rats, and squirrels. Squirrel here are not to much of a nuisance they will get into feed and sometimes automobiles outside, but generally don't get into houses at least not here. And they aren't hard to keep out. The moth ball / steel wool trick is probably your best defense in that case.
But if it's mice and you try to block them from under the hood the next thing you know they might go down the heater duct. If it's rats that's bad news because they are just so destructive and hard to get rid of once you have them.
I would really encourage you to try to figure out what the critter is. If you think it's mice set some traps under the hood. You might just prevent them from getting into your house next.
I live on a farm and it's a constant battle with mice and rats. If I wasn't proactive with trapping, (I've got animals so I can't use poison) They'd be into everything I'm sure.
I just don't want to see you bandaid a larger problem by just keeping them out of the truck. Good luck however you choose to handle it.