When you hit your ball into a penalty area you have three options under penalty of one stroke if the stakes or lines are red, two options under penalty of one stroke if they are yellow, plus an additional option for no penalty… which is to play the ball as it lies if it is safe, practical and prudent to do so!
So, if part of a penalty area is dry, or a grass bank running down into a stream lies within the penalty area markings, for example, there is no problem simply playing the ball as it lies for no penalty. You can even attempt to play it if it is lying in or under water if you so desire.
Furthermore, you can move loose impediments in a penalty area (taking care not to move your ball in the process as that would attract a penalty under Rule 9.4), take practice swings or touch the ground or water with your hand or club, all of which were prohibited until the major Rules revisions from January 2019.
Assuming the stakes are red, which is what The R&A encourages them all to be these days (although yellow is still perfectly permissible), there are three penalty relief options available under Rule 17 – stroke and distance, back-on-the-line or two club-lengths lateral relief from point of entry into the penalty area. It is this final one that you lose as an option if the stakes are yellow.
It's also worth mentioning that not all options will always be practical or possible – for example, back-on-the-line won’t be an option if that line would take you beyond the boundaries of the course and it might be unwise if the only place you can go is into deep jungle or undergrowth.
Stroke and distance is always an option, though, and sometimes may be your only practical or sensible one. To proceed, you must identify where you last played from (estimating that spot if you are not certain) and drop within a one club-length arc of that reference point, not nearer the hole, before playing again under penalty of one stroke. You must drop in the same area of the course as your reference point, whether general area or bunker. If it was your tee-shot, you may re-tee anywhere within the teeing area.
This back-on-the-line option was modified a little from the 2023 Rules revisions. After determining the point at which your ball last crossed the edge of the penalty area, you may go as far back as you wish within the boundaries of the course on a line that keeps that point directly between you and the hole.
You then drop your ball on that line, and the spot on the line where the ball first touches the ground creates a relief area that is one club-length in any direction from that point. Previously, it had to be not nearer the hole than the reference point, but since you may drop back as far as you like on the line anyway, the ball rolling up to a club-length nearer the hole doesn’t really matter as you could have chosen to drop at that point anyway, hence the change.
Finally, from red penalty areas only, you may opt for lateral relief, measuring a two club-length relief area (not nearer the hole) from where your ball last crossed the edge of the penalty area, and then dropping in that relief area. This can be in any part of the course other than the penalty area from which you are dropping. If you can’t be entirely sure where your ball crossed the edge, estimate the spot to the best of your ability.
If it is not known for sure that your ball is in a penalty area, or you are not ‘virtually certain’ that it is (95% certain), you will have to go back to where you last played from under stroke and distance (Rule 18.2) for a lost ball.
Finally, it’s also worth remembering that if it is known or virtually certain that your ball is in a penalty area, you cannot play a provisional ball. You must proceed under one of the options in Rule 17 covering penalty areas rather than Rule 18.3 addressing provisional balls.