If you have Android Studio installed on your mac,
- Go to Applications directory in your Finder app
- Control+Click on Android Studio app launcher
- Click "Show Package Contents" from the popup
For me, I was able to locate the keytool file and other java executable files in:
/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin
To add this path to command line so you can run any executable file in the folder, you need to edit the terminal profile; .zshrc file for zsh(macOS Catalina or newer) or .bash_profile file for bash(older version of macOS). You can locate this file under user directory;
/Users/your_username/.zshrc
If the file is hidden, press (Command+Shift+.) to show hidden files
You can edit this file using your TextEdit app (you might need admin privilege to do this). Simply open the file and add this line, then save:
export PATH="/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin:$PATH"
Close your Command Terminal and open again. Run keytool