
There are various restrictions on touching the sand with a club in a bunker. Rule 12.2b lays out the circumstances in which you will incur a general penalty (two strokes in stroke play and loss of hole in match play) if you touch the sand in a bunker with your club before making a stroke.
You can’t touch the sand with your club to test the condition of the sand. You can’t touch the sand right in front or right behind the ball with a club unless you are fairly searching for the ball or moving a loose impediment.