The short answer is: You can’t. At least not reliably.
The main problem with boundary training is that even though you probably could teach your dog (while he is on a leash and you are attached to the other end of it) where your property line is, the minute you weren’t outside with him and he saw something that he wanted (think squirrels, people, cars, rapidly moving air molecules), he would more than likely run straight over that line, to infinity and beyond.
Your dog doesn’t have the ability to see something he wants to chase (a moving car, for example) and then reason it out (“but if I run in front of it I’ll be seriously injured”) to avoid a bad outcome. The dog never thinks “Well……my owner was very clear about not wanting me to leave the yard, so I’d better not.” Maybe (big emphasis on “maybe”) he wouldn’t leave if you were standing next to him while he was on leash, but if you’re inside the house, or not home at all, your dog can and will leave the property.
Does that mean an invisible or hard fence is invincible? Not at all. Is it a safer option then nothing but wide open space and a prayer? You better believe it.