I haven't tried LuaMacros with Elite yet, but if it will work with it, which I guess it will, you'd be able to program a toggle-switch to send an emulated keyboard key-press on the toggle-switch operation. Say - send 'g' on toggle "ON" event, and on toggle "OFF"' event (just button press/release).
You could do a toggle-to-momentary mod using basic electronics too (using a relay and a capacitor, and power source, obviously). But if it's a HOTAS setup you use in other games, that's probably not something you'd do. There also might not be enough place for it.
You could use a number of other keyboard/joystick software that lets you program macros.
But none of the above is ideal. A native solution would still work better - if a switch was flipped while the game wasn't registering events (alt-tabbed, in the menus, not running, etc) then a native solution would react to it as soon as you returned to the game. Game state is always synchronized with the hardware switch.
Software/hardware solutions above don't give you that. You get synchronization problems - if the game isn't registering events, then you can flip the switch, get back to the game and now you're flying willy nilly while the switch says LANDING GEAR DOWN, and to get the landing gear down, you switch it to a LANDING GEAR UP position, or press ESC, flip the switch so it's aligned correctly, and continue playing. Not a big deal, but it does lessen the immersion factor.
You could, in theory, get that info out of the game and let your software solution monitor if the state of the gear in-game and the state of the switch are synched, and if not, do something about it (flash a red LED? ignore next flip of the switch, so they are synched after it? send appropriate input event so that the game is now synched?)
But that's going through a lot of hoops just to get something that's done for a couple of other features already and works well. Not to mention, such an innocent thing could be picked up as hacking.