I don’t know a command-line program, but some GPX editors allow to add or correct the elevation data from DEM sources.
The general problem with this method is that the open source DEM data with its raster of 30m or more is too unprecise to calculate good elevation data. It would ignore bridges and tunnels and the fact that major roads are typically not following the surface, instead the earth is flattened before the road is build.
Some routing programs calculate elevation profiles which are more reasonable, e.g. brouter
This has been a recurring pattern on this forum recently, where a new user just copies and pastes an earlier answer. They seem to be spammers of some kind - they may intend to edit the post later to add a link, or to add a link in their profile. I have reported several such posts.