In a bunker you can't test the sand or ground your club before the shot, and you get a general penalty if you do. Otherwise it is played like the rest of the course, and you can smooth the sand after you've played out.
What counts as being in the bunker?
Your ball is in a bunker if any part of it touches sand inside the bunker's edge. If it is on soil or grass inside the edge and touches no sand, it isn't in the bunker.
What can't I do before my shot?
Don't deliberately touch the sand with your hand, club or any object to test it. Don't touch the sand with your club right in front of or behind the ball, in a practice swing, or on the backswing. The penalty is two strokes in stroke play (the hole in match play).
What can I do?
You can dig in with your feet, rest or lean on a club, put your bag or clubs in the sand, and clear loose impediments and movable obstructions such as a leaf or a rake. Touching the sand while marking or measuring under a Rule is also fine. Don't improve the conditions for your shot, which is a separate penalty.
Once your ball is out of the bunker, or you are taking relief outside it, you can smooth the sand freely.
What if my ball is unplayable in the bunker?
For one penalty stroke you can go back and play from the last spot, or drop within the bunker on the line behind the ball or laterally within two club-lengths. Dropping back on the line or laterally has to be in the bunker. For two penalty strokes you can drop back on the line outside the bunker instead.
The governing rules are Rule 12 and Rule 19.
Local rules
Your league's committee may have local rules that change this. Ask the organizer which ones your league uses.