Manual:$wgNonincludableNamespaces

Details
Pages in namespaces in this array can not be used as templates. Elements must be numeric namespace ids. Among other things, this may be useful to enforce read-restrictions which may otherwise be bypassed by using the template mechanism.

Older versions
This setting was introduced in MediaWiki v1.10.0.

Older versions of MediaWiki may acquire this functionality (and the protection it can provide) by installing the NonincludableNamespaces extension.

The extension also adds some extra settings to make configuration slightly easier for the most common use-cases and may be safely installed on versions > 1.10.0 if you just want access to these new settings.