Can I undo text changes that I made using the User Interface Text tool if I haven't published the sandbox?

It depends on types of text changes in the sandbox. If you want to undo all text changes done in the user interface and global menu label, delete your sandbox before publishing it.

Note: However, you can't undo the text changes done in messages and enterprise scheduler.