Step 1 : Go to Spotlight Search and type Terminal and Open it,
Step 2 : Now browse to the location where the file or folder is present using cd command. (eg. if the file is situated on the desktop : cd /Users/your-mac-user-name/Desktop/
Step 3 : Now simply type gzip followed by the file name with extension.
Example for single file : gzip filename.txt
Example for dir : tar cvf - myDirToCompress | gzip > myDirToCompress.gzip
Warning : When you gzip compress file using gzip command on the Mac the original file is deleted!!