Manual:$wgNonincludableNamespaces

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.

Use like: $wgNonincludableNamespaces[] = 102;