By default undo does work in the scratch buffer so it is something in your configuration that is keeping this from working. As a quick way to check, try running emacs -q
, which skips loading your configuration, and see if you have undo in the scratch buffer there; if so, it's definitely something you have in you configuration.
You can bisect your configuration to figure out how you are deactivating undo. You can do this manually or with the help of the bug-hunter package.
I use it in all buffers whose major mode is derived from text-mode.