It is indeed very satisfying to go over the finish line of a challenging event with your hands in the air!
So...
Practice on a smooth, quiet road or path.
Don't have anything heavy on the handlebars, like lights or bar bag.
It's much easier if you don't have anything else attached to the bike that can affect the balance and steering, like drinks bottles and rear luggage but these can be added once you have mastered the skills.
It's easier to balance if you look ahead rather than what your hands are doing.
As others have said, get a bit of speed up to keep the momentum and it's easier to keep peddling in a high gear so you are doing quite a low steady cadence.
Start with one hand. When you are really confident, riding with one hand, lift the other hand off the bars just a few inches. When you can keep going like this for a while, then gradually try sitting up for longer periods.
Pretend that you are going over the finish line!