Since current >7 speed cassettes have so fine spacing between the gears, about the only reason why you'd want to install a cassette with more gears is wanting to get more range.
A 9-speed freehub will take 11-speed "MTB" cassettes (that have a large big cog) but not 11-speed "road" cassettes (that have a small big cog). So 11-42 is a go, but 11-28 is probably a no-go. The reason is that 11-speed cassettes are wider. "MTB" cassettes with a large big cog have the big cog shaped to overhang the hub flange, but "road" cassettes have a small big cog that can't be shaped in such a manner, there's simply not enough space for that.
The main difficulty is replacing the shifters and rear derailleur. You also need to replace the chain, which might necessitate replacing the chainrings as 11-speed chain on 9-speed rings may be asking just a little too much.
If you have a drop bar bike, and have to use 11-speed "road" shifters, they use a different cable pull ratio incompatible with "MTB" equipment. So you may not find a compatible "MTB" rear derailleur, and "road" rear derailleurs don't support a 42-tooth big cog.
If you have a flat bar bike, things are easy. Replace the shifters, rear derailleur, cassette, chain and chainrings.
Another possibility is replacing the rear hub with a "road" 11-speed hub if you use drop bars. In such a case, you need to replace shifters, rear derailleur, cassette, chain and chainrings and additionally the rear hub which requires rebuilding the wheel.