Meta (M) symbol is the Esc key in OSX.
To undo a change in nano, press ESC and then U (i.e. one after another, not together).
Note that UNDO is not supported in the default MacOS provided nano (V2.0.6) — to get the latest version:
brew install homebrew/dupes/nano