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.