Here are a few things you can check:
You mentioned checking the grounds under the hood, but also look for ground connections specifically for the rear lights. A bad ground can cause strange behavior like what you're experiencing.
Sometimes the bulb sockets themselves can get corroded or have a poor connection. Make sure they are clean and make a good connection with the bulbs.
Visually inspect the wiring harness for any signs of fraying, corrosion, or shorts. Pay close attention to areas where the wires might rub against the body or frame.
If everything else looks good, the issue could be coming from the turn signal switch (multi-function switch). This isn't uncommon by any means.
If you have access to a multimeter, you can test for voltage at the light sockets with the headlights on and off to diagnose if there’s a change that shouldn’t be happening.
Hopefully, one of these suggestions leads you to finding the root of the problem. Good luck, and let us know what you find!