Different manufacturers have different methods to do what you describe. I'm familiar with TCS and ESU decoders. TCS uses BackEMF from the motor to adjust the sound. ESU has a function button that changes the throttle inputs from controlling the speed to controlling the sound. ESU also has a function that mimics a load on the engine. Pushing that function will advance the throttle an amount set by a CV. There is also manual control of what notch the train is in. Another function is 'straight to eight', ie full throttle.
In my experience, I swapped out the TCS decoder I had for an ESU Loksound 5 and mostly use the "load function". Usually I'm just switching and want to change the speed at the same time as the sound. ESU also has a function to drop the engine sound to idle. A switching move might start with pushing the load function, wait until the prime mover starts to spool up, advance the speed throttle, move some distance, turn off load function, roll a little farther, hit the idle function, slow the train to a stop using the brake function as necessary. I've remapped the most used funtions to the most easily accessible buttons on my throttle.
Starting a heavy train from a stop might be turn on the function to control sound and not speed, turn it on for short periods (seconds) to let the train start moving, turn it off, turn it on, off, on. This lets the train slowly speed up to match the throttle setting while making the sound of a train pulling much harder.