A proper looping should work out-of-the-box in a good physics engine. "Proper" in this context means that the upside-down section is constantly curved. As long as the curving forces the vehicle to change its direction, the resulting
centrifugal centripetal whatever force should cause it to cling to the track.
If it doesn't work, then possible reasons could be:
- The vehicle is not fast enough
- The looping is not tight enough
- The collider of the looping is not smooth enough
- You are somehow adding artificial force or torque which interferes with the simulation
- The physics engine itself is not very realistic
But when you want the vehicle to drive through a half-loop and then drive along a straight segment upside-down for a while without falling: I'm sorry, but this is not how physics work in real life. So if your physics engine makes the vehicle fall off in this situation, then it is working as intended. So if you want the players to be able to drive on the ceiling under certain conditions (which I can understand, because it looks and feels awesome), then you need to cheat. Detect this situation and temporarily switch off gravity for that vehicle. Remember to switch gravity back on again if the wheels disconnect from the straight section for any reason, if the player breaks or if the straight section ends.
I'm looking forward to playing your game.