From what I understand, the usual way to campfire-cook an egg (without pots'n'pans, I mean) is to pierce a little hole in it on one end, I think on the large end so the bubble of air leaks out before any egg does, and then partially bury it right next to the campfire so it bakes slowly-ish. I've heard of burying in earth or in ashes, depending on one's setup. You can cover the top with a leaf (just make sure you know what it is a leaf of) if you're worried about something dropping through the hole while it cooks. it does take a while, like ten minutes or so, it is a tradeoff of a slower method of cooking for a higher chance of not blowing itself up. I've seen it done, it works pretty well.
So I mentioned campfire cooking since you talk about hiking, and because it's the closest method I know of to what you're asking, but since you're talking about a barbecue setup... that will be a bit trickier, since there's no convenient heat-sink right there to leave the egg in to bake.
The solution would probably be the same, though, it needs to be buffered from the heat so it bakes slowly (suddenness of temperature shifts or physical expansion being very good for explosions). Piercing might still be helpful, though, depending on how fast or how hot it is cooked.
Loosely wrapping in leaves or other, hm, disposable wrappings. I've seen suggestions of using a hollowed potato or an orange peel, just anything thick, moist, slow-burning, and nonpoisonous you might have on hand. Even foil might work, though it'd take quite a bit to get a proper loose thickness since it conducts heat much better. This method will make the heating a bit slower, and slower is less likely to explode, etc. Again, don't just grab any random leaf, make sure you know what kind it is, if it's going to be in contact with your food. Maybe even a clay or mud coating (optional inner foil to keep the egg clean), I've heard of it being done for fish and the like.
If you can find or make somewhere conveniently nearby the heat where the egg can be left, that might work too (especially if it gets quite hot). Some metal shelf or hanging container or even something tucked right up underneath might work quite well, though this solution might take a bit of rigging depending on your setup.
Third option would be, if you're eating anything else with your egg (like beans, or anything saucy) you can poach an egg right on top. You can just crack it on and let it cook, it's a known technique (a recipe would be something like "eggs in purgatory" which uses a tomato based sauce though one can use anything wet or saucy). If you're cooking something more solidish and not saucy, like chopped veggies, you may be able to plonk your egg in with them, in the shell, and just let them serve as a temperature buffer.