There are many ways to regulate the distance and height of a bunker shot, but the one I find easiest for my students to execute concerns the finish position. With this method, the length of the backswing and the swing speed stay consistent, but the length of the follow-through changes depending on the distance and height you want to hit the ball.
To get the hang of it, start by hitting two shots. Take the club back to the same position and swing down at the same speed, but finish low the first time and finish high the second. You'll find the low finish is ideal for a short bunker shot that doesn't require a lot of height. The high finish, however, is better for longer shots in higher-lipped bunkers.
Whichever finish you use, remember to release the club by having the clubhead pass the hands. This ensures you won't leave the club stuck in the sand. A final thought: As you swing down, be sure to rotate your weight to the front foot. If you hang back, you'll struggle to slide the club under the ball.