You can easily script this if you know the list of tiles that make up roads. For a given road tile, look at the 4 neighbors. If they are roads or not, you have different cases. This way you have 4x4 cases: one of them being no road, it's 15 cases in which you choose which tile to put and how to flip/transpose it.
That's the easiest way, but if you like binary there is a clever way using bit masks of 4 bits, where each bit is a direction where the road tile can go. You then obtain a number between 0 and 15, and you map it to a tile ID and flip/transpose.
This question comes up a lot in 2D game dev, I'm sure you can find more examples and variations on the web, it's not specific to Godot ;)