I detect a couple of questions in your post so I'll try to separate them and answer them individually.
Do I need to be anonymous when doing penetration testing?
No, you need the opposite: a signed contract. You will have a lot of contact with the client to establish scope, launch the test, report any problems encountered, and to deliver the findings. Same as any other job.
I think it's helpful to understand that "ethical hacker" is more of a cultural/political/economic term than a technical one and that might be leading to some confusion here.
Learning about anonymization typically won't be covered in an "ethical hacking" course because these courses are designed for professional development, and in the context of business you don't need anonymity.
How do I confuse a firewall about my identity in order to prevent getting blocked?
If you're talking about getting around a firewall, that wouldn't be "anonymity" but rather "evasion". When running automated tools you'll inevitably bump up against different kinds of firewalls which will block you. There are evasion techniques to deal with these but again this is evasion, not anonymity. Commonly you can evade firewalls by tweaking your tools or by spoofing or rotating your IP address. It would be good to learn about this so that you can learn how to get around common defenses.
How do I stay safe online?
You also mentioned "real hackers" which by context I understand you to mean people looking to cause harm to you online. This is where anonymization might really come into play.
Your defenses against people looking to cause you harm will depend a lot on who those people are: nation-states? an ex? attackers looking to take over your Netflix account? It also depends on who you are, where you live, and your tolerance for risk.
These aren't easy questions to answer but there are good resources out there to help. There are sites like Surveillance Self-Defense that can help you with creating a plan to help protect yourself online (also referred to as "Threat Modelling").