That’s a bit of a challenge, … some dogs never seem to learn not to bark when they are left. You could always try one of those collars designed to spray citronella when the dog barks (although someone I know used one on her Golden and it loved it, started barking to “get a fix”), but a lot of people including dog trainers have had good results with them.
I needed it for a very different reason but it might work for you too, I bought a Kong Stuff It Ball (or the name is very close to that, might not be right on), and my Shepherd loves it! I bought one for my Mother’s over active small dog (dear only knows what is in him, probably Terrier and Chihuahua, that boy Never stops!) and he adores it. You fill it with treats, and you can (its a good idea) smeer a little something like peanut butter (or they sell pastes liver and such) inside it along with some biscuits or the like and hand it over. Takes them some time to work the goodies out (and that’s why the soft stuff like peanut butter is great because its tricky licking the inside clean) it can keep them occupied for hours. (Depends on the dog of course.) I was worried since my Shepherd is truly not food oriented but he can’t get enough of it. And after a year of his “Playing” with it its still in good usable condition, … and that is a true testamony to its durability! Point is chances are if it doesn’t solve the barking problem it most likely wouldn’t be a waste of money anyway.
But think he does need to be distracted/occupied when you leave, or (not as attractive) punished (as in the collar) for the barking. Probably trying to train him not to bark by repeating the routine won’t be helpful since you are sending the opposite message from the one you want him to get; you leave, he barks, you come back in, … you’ve given him what he wanted in the first place. I know and you know you planned to come back in all along, but he doesn’t know that.
Good luck and I hope someone else has some more helpful ideas for you.