The PC can try anything
Let's get back to basics. The game flow goes like this.
Case 1: the DM assesses that the outcome is not in doubt.
- The DM describes the environment.
The DM describes the PC being in (for example) a room, or a cave, or standing in the village square.
- The players describe what they want to do.
I want to punch myself
- The DM narrates the results of the adventurers’ actions.
You punch yourself.
Player then asks: how much damage do I roll for?
DM asks: Were you trying to harm yourself?
Player answers: Yes.
DM says either:
You successfully did (1+STR modifier) damage to yourself
or
Not your day, you didn't do any damage to yourself
We note in Chapter 7 that the DM should not call for a roll unless the outcome is in doubt. While that is aimed at ability checks, it can be applied here as well, so ...
Case 2: the DM sees that the outcome is in doubt; a die roll is called for.
- The DM describes the environment.
The DM describes the PC being in (for example) a room, or a cave, or standing in the village square.
- The players describe what they want to do.
I want to punch myself
2a. DM calls for a die roll: roll a d20 versus your armor class, with advantage {or with disadvantage} On a hit, do 1 + STR modifier damage to yourself; on a miss not your day, you tried to punch yourself and missed {hilarity ensues}
2b. Player roll turns out as a 15 + mods, and scores a hit, and has a strength of 16.
- The DM narrates the results of the adventurers’ actions.
You punch yourself. It hurts quite a bit, you take 4 points of damage.
A DM can apply circumstantial advantage or disadvantage to any situation where it seems appropriate. This DM would. @NautArch points out that it is kind of hard to hit yourself IRL, so it may be more "realistic" to apply disadvantage rather than advantage.
The result of a hit may be zero damage, though
With a Strength score of 9 or less, there is a -1 modifier to the attack, and 1-1 = 0. This was confirmed in the 2019 Sage Advice Compendium, page 11.
Can damage be reduced to 0 by resistance or another form of damage reduction? There is no damage minimum in the rules, so it is
possible to deal 0 damage with an attack, a spell, or another effect.