There are a bunch of handlebar plugs here on Thingiverse already, and several really nice designs. (This one is particularly nice and I've printed and used it on several of my bikes. The only issue I have with most of the designs is they're heavy, or they don't fit my bars. I set out to address both of these issues, and what we have here is the culmination of several month's worth of design variations which I've been testing extensively.
The design is minimal - the outer diameter of the plug is 22.2mm (7/8") which matches the outer diameter of MTB handlebars.This allows the plugs to stay in place when grips are installed or removed. The design is sized to the inner diameter of the handlebars, which you'll need to measure. (or print several and see which fits) For instance, the 17mm size fits my ENVE bars, as well as my wife's Bontrager XXX bars. The aluminum bars that came with my XC bike has thinner walls and so they use the 19.5mm diameter size. The design is parametric, but to make life easier, I've included STL files in a range of sizes from 16.5 to 20mm. The Fusion360 F3D file is included if you wanted to make any further changes. (see the section below for notes on that)
These things are light - see the photos, a current set of ESI plugs is about 4g and these come in at 2.5g in the 20mm ID size in PLA. Yes, this is ridiculous weight weenie territory, but I'm not aware of any option that's lighter, aside from running no plugs, which is a bad idea as that's kinda dangerous. Of course, if you wanna be really fancy, you can always spend $20 on a set of carbon fiber plugs which weigh over double as much.
I've printed using PLA, PETG, and ABS. PETG and ABS are best if your bike is subjected to high temperatures (like sitting in a car on a hot day) but any of the materials should work.
No supports are needed, and you can use whatever layer height you wish. I suggest using enough shells to make the piece solid, although a little infill in the end of the cap isn't a big problem. You do want the part that inserts into the bars to be solid, however.
The design of these plugs evolved over several months as I tested them on several bikes, both mine and my wife's. They've been tested over several hundred miles of riding, in the deserts of Utah and Arizona, Kingdom Trails in Vermont, and various Cat 1 and endurance MTB races in the northeast.
My initial prototypes were printed in PLA, and I had issues with them getting loose and falling out. I thought this was due to the less than perfect properties of PLA, so reprinted in PETG and ABS, but those wound up falling out as well. Turns out I had designed them too thin, and after a while, the plastic would reshape to no longer be a press fit into the end of the bars, at which point it would get loose. Adding a small taper to the inside of the plug thickened the walls slighly and prevented this. The current design has been in use on several bikes with no issues.
I also ran into issues where the plug would break quite easily if I hit a tree with the bars. The obvious solution is don't hit a tree with the bars, but adding a fillet to the inside increased the strength and made this less of an issue.
The current design has been in use on several bikes for well over a month with no issues.
Notes for modifying in Fusion360
If you download the F3D file and import it into Fusion 360, you can use the "Modify" "Change Parameters" command to open the little spreadsheet where you'll be able to modify the user parameter "Bar_inner_diameter"
The text marking the size inside the plug is static, and not driven by the "bar_inner_diameter" parameter, as you can't do that in Fusion360. It is also manually centered, as you can't easily center text in Fusion360 So, if you modify the bar_inner_diameter, either update the text in the last sketch, or delete that part altogether if you don't need it.