Yes, it is possible to install a 7-speed cassette on the 11-speed hub, but this setup requires spacers under the cassettes, you have to buy compatible hub spacers, but you also have another alternative option, you can use the old traditional freehub, a 7-speed cassette are different in with and diameter than an 11-speed hub, 11-speed hubs are wider and thicker in diameter. but you also have to look for new gear shifters, the reason is that 11-speed shifters are not compatible with the 7-speed cassettes and vice versa. and also you have to adjust the barrel adjusters of the gear shifters to maintain the length of the cable, it is important, otherwise, the gear shifter cable won’t work due to being shorter or longer length.
The width of the spacers would also matter for the accurate lining of the chain, before buying a spacer measure the width and size f the spacers, so that they would be compatible with the hub and the hub remains firm and accurate in its place above the hub. chain lining is much important because it will improve bike speed, and decreases the friction of the chain with the cogs and teeth of the cassettes. 7-speed hubs are not strong as firm as 11 and 12-speed hubs, so this setup would also require stronger and more durable rear wheels with the 11-speed cassette.
The shorter or greater length of the cable shifter is called cable pull ratio, it will affect the cog pitch of the cassette, and you will feel issues or problems in shifting the gears from smaller to larger or larger to smaller cogs of the cassette, all these things would matter for making 7-speed cassettes compatible with the 11-speed hubs. but there are a few categories of gear shifters that are not compatible with derailleurs and cranksets of different speed bikes and this brand of shifters is known as Dura-Ace shifters, if you have also installed gear shifters of the same brand, then you have to change or replace derailleur and crankset of your bike with the new compatible parts.
Re-lacing and re-dishing of wheels are also important for replacing bike hubs and cassettes because the length of the spokes is compatible with the previous hub flanges and sometimes you have to buy new spokes to measure the accurate length of the spokes. as a result you have to re-dish your rear rim. tensioning of the wheels disturbs a lot which will also require checking the tensioning of the wheel or re-lacing. drive and non-drive side of the wheels 7-speed and 11-speed wheels have different tensioning, based on this different wheelsets of both of these bikes are not compatible with 7 and 11-speed hubs. weight of the wheels is also different for both of these wheels. rear dropouts of the frame and clamp holes of the hub axles would also matter a lot regarding frame compatibility.
Derailleur contains two screws which are known as limit screws, these screws need to be adjusted properly by tightening and loosening. you have to make the cable pull and cable pull ratio of the derailleur compatible with the gear shifters.
Size Of Spacers:
4.5mm spacers are needed for making the 7-speed cassette compatible with the 11-speed hub, you can also use spacers on the non-drive side of the hub, but smaller 3mm sized spacers are installed on the non-drive side of the hub.
Chain linning also depends on the bottom bracket of the crankset, if the chain lining is not accurate and gears are causing problems when shifting between the cogs and teeth of the cassette, then insert the wavy spacers on the non-drive side of the BB to make the setup compatible with the 7-speed cassette.
Wider and narrower chains of 7 and 11-speed are non-compatible with each other, and if you are persisting to install an 11-speed chain on a 7-speed cassette and vice versa then you are ruing your chain ring and teeth of the 42 cogs and teeth of the crankset, you have to buy a new compatible 7-speed chain for 7-speed setup.
It is the width and size of the hub, if the OLD of the 11-speed hub is compatible with the bike frame and 7-speed cassette, then the setup will also work without any issue or problem. hub OLD depends on the bike frame for compatibility.