To map the caps lock key to escape in macOS, open System Preferences > Keyboard. Click the Modifier Keys... button. In the dialog you can choose to map the caps lock key to escape, as well as other actions.

Screen Shot 2017-12-05 at 11.19.48 AM.png
Community content is available under CC-BY-SA unless otherwise noted.