Exporting overlapping material to gltf format
The glTF exporter in Blender won't use materials that aren't assigned, and as mentioned in the comment above, only one material may be assigned per face.
But, glTF also has a relatively new extension called KHR_materials_variants that allows certain viewers to automatically swap between materials on an asset.  Check out the announcement of that extension which includes an embedded demo.

I haven't tried this myself yet, but you may also want to take a look at a Blender glTF material variants plugin which is in early devlopment by one of the ThreeJS/Hubs contributors.  It actually plugs in to the existing glTF addon, creating some new Blender UI for assigning multiple materials, while still making use of the official Khronos glTF exporter for the final result.
There's also a glTF Meld Tool.  I haven't tried this either, but this tool is said to take glTFs with identical geometry, where only the materials are different, and automatically meld them into a single glTF with KHR_materials_variants applied to it.