
This is one of those questions where some golfers perhaps think this is a complete no-no and would be looking to try and penalise you the moment the rake touches the sand. In reality, the answer is actually both ‘yes’ and ‘no’.
Rule 12.2b holds the answers here (‘restrictions on touching sand in bunker’). One of the key distinctions is that when your ball is in a bunker, you may rake the bunker at any time to care for the course as long as you do not improve the conditions affecting your upcoming stroke (this means to improve your lie, area of intended stance, area of intended swing or line of play). If your actions in touching the sand with the rake were to improve the conditions affecting the stroke you’re about to play (for example, raking a deep footprint right behind where your ball is lying), that would get you the general penalty under Rule 8.1a.