If you can get past the funny factor, perhaps this product will work for you. Hammacher Schlemmer’s description sounds promising:
This is the patented harness that prevents puppies or small adult dogs from escaping fenced-in areas. The device slips on a dog like a common harness, but its integrated rigid 10 1/2″-long cross-bar spans well beyond the width of the pet, preventing it from slipping out between fence railings.
The lightweight harness won’t inhibit a dog’s movements and allows passage through most standard pet doors. It is made from a 100% woven nylon that pets won’t find irritating, and has adjustable straps to ensure a snug fit.
With a retail price of around $30, this affordable contraption may just do the trick – if your dog will tolerate it.