What to do
First, have the dog sit and tell them firmly (but kindly) to stay. Personally, I like to have dogs on hand signals too so paired with the "stay" position your hand as depicted in the picture below with my dog, Razza.
Tallinn was actually great at picking up stay given she doesn't really know sit or down yet. I found that rushing away while she was busy chewing her last piece of treat worked wonders because she was too distracted to care.
After the dog starts staying semi-reliably start to add a release word like "okay" to free the dog before rewarding them. For most dogs this is more than a few sessions into learning what "stay" means so feel free to wait to introduce it.
In the future, I would consider trying having a second person hold the dog to give a more excitable dog a better chance at staying to be rewarded. Just teaching the concept of staying in one place is difficult in the beginning so it's just not worth it (unless your dog already knows either sit or down) to discriminate as long as they're staying roughly in the same space.
Tallinn's Best Attempt at Stay
Note: Tallinn was already quite tired from an earlier long dog walk.