I want to know if it is safe to hash a file in a non-sandbox environment.
Unless the target of the malicious file is the hash program itself, it is safe, because the file is only use through it. And hashing program are normally simple enough to not suffer from such vulnerabilities. So IMHO it is safe if you use a command line hashing program.
"Unless the target of the malicious file is the hash program itself" is why I voted for this answer– niilzonJun 14, 2017 at 10:34
Hashing just reads the file and does not execute it. If in doubt make the file none executable.
I don't know of any hashing program which would require to execute the file being hashed. It should be safe enough. Just to be sure, make the file as read-only and put it through the hashing program.
Alternatively, you can upload the file to virustotal.com. It hashes the file to some popular formats like MD5, SHA1, SHA256.