I trained both of the dogs I've owned to go on command. In my case the phrase is "hurry up"! One was a puppy and the other an older rescue dog.
I got the technique from a dog training book written by the Monks of New Skete. They train lots of dogs and their book has been in print for many years.
First, you take the dog out when it should need to go, such as 1st thing in the morning. You stay with it on a leash until it goes, then say what ever your phrase is as it's going and reward with a treat and lot of praise/petting. You do this over and over again for a period of days. You can also say your phrase and give a treat when it starts to go while you're taking it for a walk. If your dog hasn't gone when you're out and you can't watch to catch it while it's getting ready to go (usually they have some "tell," like walking in a circle, etc.,) then you may want to keep it in a crate to prevent it from going inside and take it out again soon. One trick the Monks recommend is to put the dog on a leash and keep it close to you in the house as you go about your work, so you can catch it before it starts to go and run it outside.
Next, you start taking the dog out, saying your phrase and usually it will start to go. (If the dog hasn't learned yet, go back to the first step for a while again.) After it finishes, you reward it with the treat and lots of praise. My dog sometimes takes up to a minute to actually go because he has to find the perfect spot by sniffing around in circles! After a few weeks of this, you can drop the treat and just do the praise.
This is a valuable "trick' for a dog to know, because you can then ensure they go if you're going to be leaving them at home for a while. Even if my dog's gone recently, he will go upon my command again, so I know he can make it home alone for some time without having an accident.
As someone else recommends, you may want to consider a dog training class to learn the basic principles. Most of the time, the principle is catching the dog doing the right thing, rewarding/praising it and repeating lots of times!