I don't think you can do that. If you go to your keyboard settings in System Preferences, you can define new keyboard shortcuts for Mail. You can define one for the command "Close," (which you can already get via the CMD + W combination, by the way) but it doesn't want to allow you to define a keyboard shortcut that consists solely of pressing the ESC key. But you can do CTRL + ESC, for instance, in case that's good enough for you...
Hope this helps