There's a slam dunk school in the game, just go in there and practice.
But the basics of it is that you push a button for a specific take off, and then you hold a button for a certain dunk. There's a lot of timing in it, but practice makes almost perfect...