Duncan Drake's answer suggests one little extra possibility.
When I mention the bayonet here, bear in mind I do so 40 years after asking a Vietnam vet why anyone would ever use a bayonet and he said no one would if they still had bullets left which I've always thought made so much sense that I've not ever challenged it in my mind. (Lol, after all, it matched my thinking exactly and that's always convincing, right? But it framed the point so perfectly for understanding it.)
So, the bayonet. There you are in this world with no bullets but a loaded gun and involved in what people usually call melee combat, meaning, no guns and really meaning, no bullets. Bayonets are always presented as
STABBING weapons, in any context I've ever encountered right down to WWI German overcoats apparently being designed to resist said stabs and nothing ever said about slashing. I'm sure a slash or seven would be used if one thought it helpful, but bayonets seem to be stabbing weapons.
So you stab. ANY amount of damage you do in the stab is all to the good, and will be whatever you managed to achieve. But THIS gun is loaded with a full charge, or more, of black powder (where Frank's gun (the vet, above) would have had no bullet or any kind of charge since it was meant for bullet firing). So you COULD, the moment you achieve most of your stab, fire the powder directly into the place of insertion (slightly off, but...) and do all the damage the above answers suggest, but dead on a torn open place on the body. Very close to that body and the hole just made (might fire as pulling out rather than at deepest insertion) that powerful blast would likely have much more serious effect, especially if it did successfully enter the body's interior. At the least, it seems to me the open wound might be terribly enlarged, a nice result in itself.
That might also give you some respect as a man with a "real" spear (the thing a bayoneted rifle comes closest to) or sword grins at you as if you're a dead man and closes in. Anything making such a creature hesitate or not just berserk me is good in my book.
Also consider how it could affect something like a shield. A little care if you can could have you fire right at the part opposite the holder's forearm which, if reasonably close, might even break that arm, quite reducing his effectiveness against you. Additional odd things in this category might include that you can pick your target differently than "going for a kill, always" suggests (a FINE approach, if it is available to your circumstances, but this might not be such a circumstance, so small gains ending in a dead enemy could the good thing to aim for). For example, aim at a foot or knee. The massive punch described above would seriously reduce your enemy's chances. Perhaps in the frenzied parry and thrust, you might get a chance to target the weapon-holding hand. Further, anything that impacts the eyes even partially could be devastating. All little things, desperations perhaps as the properly clad and armed enemy moves in to kill you, but could be gamechangers if they succeed. And when pointing downward, another target most can figure out might be clad in a strong metal cup, so to speak, but the hammer blow others describe could make the phrase "scraped off" apply which should take the steam out of an attacker ...
Surely such a world would see you carrying the gun, usually, as a complete extra to your own proper melee weaponry, but as Frank said, broadening the concept, not the point, you use it (gun in this case, not a bayonet, but still a definite "down the list" choice) when what you really use is not available. Perhaps why you slung it on rather than not carrying the 5-15# extra weight. Maybe an extra sword would've been a better extra, but you had a rifle, not a second sword, so...