locate `pre-commit` and not `pre-commit.sample`
locate uses shell-style globbing so the options for the pattern are kind of limited.
The simple way probably is to just run
locate pre-commit | grep -v 'sample$'

Or you could make use of the special case documented in man locate
As a special case, a pattern containing no globbing characters (``foo'') is matched as
though it were ``*foo*''.

and use locate 'pre?commit' (quoting is required to prevent the shell from expanding the pattern) to prevent the automatic adding of the * wildcard.