/fill <x y z> <x y z> <id> <data> <replace/masked/filter/specblock/normal>
Specblock would be able to make any block spectator resistant. The id and the damage value is the block the command should turn into a spectator resistant block. To turn it back to normal, just use the same command but with normal instead of specblock.
This is a fantastic idea, but it requires any kind of block to be a data holder. Currently, only blocks such as chests can hold NBT data. With this new fill type, blocks like stone would have to hold the property of specblock, which would be set to 0 by default. If you used this fill command, the block would then have the value of 1 for specblock, which wouldn't allow spectators to fly through it.
My suggestion is having a gamerule for spectators going through barrier blocks. The gamerule would be called spectatorThroughBarrier and by default it is set to true. To change it, the command would be /gamerule spectatorThroughBarrier false, which would not allow spectators to go through barriers.
In my opinion, one of the largest perks of spectator mode is being able to no-clip through anything. This allows greater freedom in exploring and observing. I personally want it to stay that way, but this is a great suggestion.