Manipulating Stash's repo/branch permissions is one way to achieve this, as Christian's answer suggests. Going into the UI to do this could be a bit cumbersome, though. If this is something you want to be able to do quickly and/or regularly, you could consider using the Stash REST API to automate or simplify the process of locking down a repo.
Alternatively, you can inject custom logic into Stash's pre- and post- git commit hooks using a Java API. Here's the (admittedly, marketing-spun) description of the feature. There is already an existing Stash add-on on the Atlassian Marketplace which appears like it may suit your needs, although I have not used it myself and cannot actually recommend if it's any good: https://marketplace.atlassian.com/plugins/com.risingoak.stash.plugins.stash-broken-build-hook
If you want to get your hands dirty, you can write your own pre-commit hook to do this. If you're already familiar with building Atlassian plugins, you can start here: https://developer.atlassian.com/stash/docs/2.2.0/how-tos/repo-hook-examples/async-post-receive-config.html
If you've never built a plugin before, you should go through this tutorial first: https://developer.atlassian.com/display/DOCS/Set+up+the+Atlassian+Plugin+SDK+and+Build+a+Project