To keep it short, unless it’s a dedicated “bayonet” and not a bayonet knife that can be used as a general-purpose blade, my idea is that instead of the default knife (which literally everyone across every campaign uses), the standard knife is the bayonet blade that would be compatible with their gun, if any.
Then a button to put on or remove your bayonet. Of course, since mounted bayonets are on the gun, you can’t just take out your knife anymore- You need to use the rifle melee. And if the bayonet is removed, then you can melee as normal with the knife being held as its own separate weapon.
Naturally, it won’t work on bayonets like the SMLE
Though that can be arranged by simply changing the bayonet type because they come either as a dedicated stabby-type or a detachable knife-type.