Hobby transformers are isolation transformers where the primary and secondary windings are electrically isolated. There is no electrical connection to the track.
Using a Variac (trade name for variable voltage transformer) on the 120v side of a step-down isolation transformer delivers sine wave power. A rotary light dimmer is will do the same but delivers a chopped wave. Back in the pre-Z4000 days when our ZWs couldn't deliver enough power, many of us built power supplies this way. I believe the ROW 400 used variable-voltage transformers in front of step-down isolation transformers.
There are a lot of step-down transformers of the "auto-transformer" design where the primary and secondary windings share the same wire. A lower cost way to build a transformer. This means your track is connected to house wiring. A shock risk. I considered re-using salvaged computer UPS step down transformers but all that I tested were the auto-transformer design. I suspect the old car charger probably has an auto-transformer inside.
Note that Variacs, are auto-transformers. NEVER use one connected directly to the track. Always put an isolation transformer between the Variac and the track.
Add up today's cost of variable-voltage transformers, step-down isolation transformers, and circuit protection, and you'll find its easier and cheaper to buy the power supplies offered by the train manufacturers.