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