If you use the shot stick, you can choose from a variety of dunk animations depending on the direction of your shot stick. Generally, you can dunk by sprinting towards the basket (R2 for PS4, RT for Xbox One, ZR for Switch) and either moving the shot stick in any direction or pressing the shot button (square for PS4, X for Xbox One, and Y for Switch).
Rocking the rim with a monstrous dunk will definitely get your performance included in the game’s highlight plays. There are plenty of ways to score in NBA 2K18, but dunking is one of the few moves that you’ll never get tired of seeing.