It depends on how you have implemented your game so far, but there are already examples of implementation of such a feature in the forums.
Try to make a search using the keyword "Top down" "GTA" "Vehicles" in the request and you should find some examples.
Otherwise, it is mostly an idea of when you are not controlling the character itself, you hide it and make the vehicle the object you control in priority.
And once you get out of the vehicle, you make the character object the main priority for controls again.
Using boolean variables, to handle the current state of the game is key in that process.