Under the old rules, if you found your ball inside of red or yellow stakes but in a still-playable lie, you could play the shot without penalty, but you were not allowed to ground your club or remove loose impediments.
Now, the updated Rules of Golf allow the player to do both. Essentially, you are now entitled to treat a ball inside a penalty area the same as you would a ball outside the penalty area.
However, if you find your ball within the confines of a penalty area and do not wish to play it as it lies and instead want to drop outside the penalty area, you have the following options
(but remember: each of these options will cost you a stroke):
can be taken in both red and yellow penalty areas -- replaying your shot from the original spot where your previous stroke was made;
available in both red and yellow penalty areas -- requires the player to note the reference point of where the ball entered the penalty area, go back on a line extending straight back from the hole, and drop a ball within two clublengths of that line.
is a third option available in red penalty areas. Identify the spot where the ball last crossed the penalty area and drop a ball within two clublengths of that spot, no nearer the hole.