Good question. The first thing you have to realize is that LGMs -- when they run right into something and can't find a path around the obstacle -- will immediately return to their tank.
To exploit this you'll want to find a spot on the opposite side of the pill as you are. Select one of the build modes: mine, road, or wall usually works. Be sure that after you are done with the fake, set it back to pill or else you'll end up placing a wall and getting your LGM killed when you wanted to plant a pill (Fubar is notorious for doing this).
After you have selected a wall, for example, click on the far side of the pill such that the pill is directly in between your tank and where you want to build. The angle must be quite straight or else the LGM might actually go around the pill and build the block, something you don't want.
Some screen shots will help explain what I'm talking about.
This first one shows when you are at a wrong angle. You want to send your LGM against the flat side of the square, not at the corner.
This one shows what happens when you choose a square too far away from the pill. The angle between your tank and the pill needs to be smaller (ie, less squares horizontally between the tank and pill in this case).
This shows the correct spot and angle. You can barely see the LGM, but he's there against the pill. It will also help if you drive in an arc, acting like you are going to build.