Quote:- "The sentence can make sense without it"
Yes, but it would not be "proper" composite writing.
Consider the following sentences in English:-
(1) We have a cozy back garden which closes us from the noisy world outside.
(2) We have a cozy back garden which closes us off from the noisy world outside.
The meanings of both are the same, but would the additional "off" somehow give a better composite sense to the sentence?
So, the word 式, by itself meaning style/type, has no individual defining semantics, (just like "type / style"), unless it is paired with some other grammatical feature, before or after. For example:-
--- French cooking / French style cooking.
--- Brotherly love / Brotherly type of love.
Thus what "closed style / type" 封闭式 means, and what specific role 式 plays in it would depend on what follows or precedes it as by itself 式 is semantically "neutral". Just like when you say "type", what type?, "style", what style?
So examples of 封闭式 :-
--- 封闭式基金 -- "Closed-end Fund", as in some financial investment fund.
--- -封闭式踏板 -- "Closed / enclosed pedal", as on a bicycle.
Thus 封闭 simply means anything which has a certain "closed off" feature, (physical or otherwise), from "outside", or "outside influence" and 式 simply expresses the "type or style" of the closed off feature in question.
Hence, I suppose, this accounts for @Tang Ho's short answer because 封闭式 is too general and "featureless" on its own, though your accompanying sentence does provide a context, namely, "...四合院内便形成一个封闭式的小环境", where the 四合院内, "inside / internal courtyard" provides the 式, "the type" of 封闭, "closed" feature which gives rise to the 小环境, "micro- environment"