It is possible to do a clean install and then restore your applications and data if:
Your MacBook supports Mountain Lion (check this http://support.apple.com/kb/HT5444)
You can somehow manage to buy the OS X installer on the Mac App Store (Mac OS X Leopard can't access the Mac App Store, you need at least Mac OS X 10.6.6).
Once you have downloaded the OS X installer create a bootable USB drive or DVD (for example, see here).
Note that Apple doesn't support updating from 10.5.8 (Leopard) to 10.8 (Mountain Lion) (http://www.apple.com/support/osx/getstarted/):
If you’re running OS X Leopard and would like to upgrade to OS X
Mountain Lion, first you’ll need to upgrade to OS X Snow Leopard. You
can purchase OS X Snow Leopard for $19.99 online via the
Apple Online Store.
so the Migration Assistant may have some trouble restoring your applications and data from your Time Machine backup, or even reject doing it. In that case will have to copy your applications and data manually.
If anything goes wrong you can restore Leopard from your Time Machine backup booting from the Leopard DVD (I did that once with my old PowerBook and worked like a charm). If you don't have the media, I'd recommend that you create an image of your current harddisk (for example, see this or this).