The trick is to sort of isolate your arm and shoulder from the rest of your body when you're moving, so that your body's moving but the combined unit of your arm, shoulder, and hand carrying the drink isn't.
The only way I can achieve this is to fix my attention on what I'm carrying rather than looking at the floor or stairs as I walk, but it's much more difficult on uneven terrain. It does require a bit of practice to get the technique off pat.
I'd also say it's easier to go upstairs with a drink in hand in this way than it is to go downstairs, particularly if there's a handrail to hold onto with your other hand - I suspect because one's peripheral vision is taking in the stairway when going up, and the handrail provides more stability. If I have to carry drinks downstairs, I just don't fill right to the top, but still manage to slop it a bit anyway.
Having a tray or a saucer just means, when it slops over, it's at least on the tray and not on the floor, but doesn't seem to improve the chances of not spilling it, in fact, quite the opposite - I'm more likely to spill something on a tray than directly in my hand, but that may simply be down to lack of practice.
It might be better for you to buy yourself one of those cups with a lid for carrying downstairs.