Cut his nails as short as possible. When he does this behavior, he needs to be isolated immediately - sent to his room for at least 20-30 minutes.
At age 7, you should be able to introduce a multi-level punishment system. First time he scratches in a week, 20 minutes in time out. Second time in a week, 20 minutes time out and no screen time for rest of day. Third time in a week, no screen time and rest of day in room.