One simple approach to keep the code relatively simple and easier to maintain and extend, is to to use a grid approach, where your algorithm determines the tiles, and each tile is a separate mesh. You can see the tile approach used in this train game below:
https://store.steampowered.com/app/657240/Tracks__The_Family_Friendly_Open_World_Train_Set_Game/
The tile based approach also works in procedural dungeon crawlers such as Diablo III (and previous versions):
It can work for hills having a variety of train tracks with slopes, and curves. This may be more or less fun depending on what you like to do. I've had a lot of fun with more complex algorithms, but simpler sometimes gives you more time to create a wider variety of content.
Toy train tracks are made of a variety of pieces that click together, for possible shapes you can take a look at some of the shapes in toy train tracks.
https://www.walmart.com/ip/Conductor-Carl-42-piece-Wooden-Train-Set-Bulk-Booster-Pack-Compatible-with-Major-Brands/805295169
Now... really complex train tracks for adults that go through mountains, and over bridges are still made of a fixed set of parts that click together. Each part could be created as a 'scene' in Godot where you add and move around two spatial nodes that represent the two ends the track (or more if it's a spliter track), then the code could use the position of those connecting nodes for each of the tracks to procedurally piece them all together.
https://northlandz.com/wp-content/uploads/2019/05/worlds-largest-model-train-tracks.jpg
For this approach you could do the ground as a height map, and a tunnel entry and exit point map. Where the tunnels are just tunnel pieces that click together, and in your vertex shader for your height map, you just don't draw the tunnel entry and exit points, allowing those to be the pre-made meshes.
For simpler mountains, you could completely use the tile based approach, with tile rotation in code so you can re-use, for example, "ground-slope" tile, "ground-flat" tile, and "ground-sloped-angle" tile for all the land, then various texture maps and 3D decals put on them for variety.
Anyways, just some more ideas. Definitely you can make the train simulation in Godot, lot's of ways to get it done.