What gun? What bike?
What use? Is this for driving down the road, do you have a CC permit? Is this only for carrying it down the trail? The public road issue might mean it has to lock, and you need to have a separate locked hardcase somewhere else for the ammo.
Kolping gun boot mounts work very well on KLR's--you have to drill a couple holes in the plastic luggage deck and they mount right on. They will also mount easily to any tube-style luggage or pannier rack. My favorite spot is the off muffler side with the muzzle end of the boot braced to the pass footpeg mount and angled back to best fit the bike.
You also can use the fin-grip style holders--either on the handlebars or mounted on the rear deck (from the turn signal holes on a KLR). That makes for a WIDE load unless it is a short gun--works great for a mini14 w/ folding stock.