Hi B.,
That is called jealousy, and your daughter is still too young to manage a feeling that intense on her own without turning it against the source of the jealousy. She obviously knows that it's wrong, but she can't help herself, and it's perfectly normal for a child this age. When my sister was a baby, I'm told I actually threw a key set at her when no one was watching.
If you think about it from her perspective, this behavior makes sense: she used to be the center of attention, Mommy and Daddy's girl, and suddenly this baby is taking the time and the attention of everyone, and she's been displaced, no one pays attention to her. The idea of a baby sister was really fun when it looked like a live doll, like the babies she saw in the park, and the novelty of baby at home was interesting, but she had no idea the change was permanent. The reality of a baby home 24/7, who's crying all the time and demanding attention all the time, is not so appealing, and she probably wishes that the baby would go away.
Dealing with the symptoms by punishing her may when she hurts her sister may curb the behavior, but it'll do nothing to deal with the feelings your daughter is having. Her feelings are just as strong as those of an adult, she just doesn't have the words to express them, and the ways to deal with them in safe ways.
So first make sure to give her one-on-one time every day, to help her put her feelings into words, and make her understand that they are perfectly normal. At this point, she's probably feeling bad about herself as well because she thinks she should love her baby sister, when she feels otherwise. So take some time with her, to put in words with her what is going on "It looks you're very angry at your baby sister right now, and you want her to go back into my tummy. Am I right?", "What do you feel like doing when you see her take attention away from you?" Make sure to also validate her feelings. After all, they are perfectly legitimate, and she's feeling them. It's only the way she expresses them that you don't like. "It's perfectly normal and ok to be angry at your little sister. After all, you used to have all of Mommy and Daddy's time, and she's taken a lot of it away from you." etc.
Having her feelings validated will make her feel understood and will lower their intensity. Then you can start to work with her on appropriate ways to show her anger, if possible involving her in the process of choosing what to do "ok, we both know that hitting or scratching your sister is not an acceptable way to show your anger and jealousy. What could you do instead?" Maybe having her hit a pillow, or a dedicated doll, or anything else you and she can think of will give her the outlet she needs in a safe way.
Your little girl is having a completely normal reaction to the arrival of a new baby in the home. All she needs is to be allowed to have her feelings heard, understood and validated, and taught how to manage them in a safe way. You can of course get her to a therapist to do so, but it's not necessary. Your love is more than enough to get the job done.
Good luck!
K.