Can spray foam be used between Rim joist and exterior sheathing?
I think spray foam will be a bit of a mess applied this way, you'll get drips, and it's incredibly difficult to remove the residue if it runs down the wall.  

I would not try to seal this up air tight, I'd just rather make it less drafty but still permeable.  You may see a small difference in insulation but if it winds up trapping water or vapor somewhere unexpected, it won't be worth it.  

I think I'd pack this space with mineral wool insulation and put some kind of flashing or trim over it.  Drip edge might work for that, it's inexpensive, readily available, and easy to apply.  The rock wool won't trap water or vapor, wick water, rot or grow mold.  

I think mineral wool would be at least as much of a rodent barrier as spray foam, which isn't hard for rodents to get through, but you could use stainless steel wool instead of mineral wool if you wanted a filler that's really rodent resistant.