When doing penetration testing (hired as a security consultant to examine and test a company's security by simulating an attacker), it's necessary to have a document called "Permission to Attack" (PtA) which outlines the scope of your actions and gives you explicit authorization to perform them. The same is true with physical pentesting where the pentester emulates physical attackers (even to the point of picking locks and forging access credentials, assuming it authorized in the scope).
One must have the document with them in case they are "caught" by the organization's security. On the Information Security site, the answer to a question about this suggests that it could be better to first forge the document and, if it is accepted by security, you continue on your way and document security's failure to stop you (since a real criminal could have forged the document as well). If, on the other hand, they don't accept the forged document, then you provide the real document.
The following is from the accepted answer (emphasis in original):
If you don't have your Permission to Attack with you, it's like driving without a driver's license. That said, if you are caught during an engagement, I recommend the following:
Present a forged Permission to Attack. This way, you can see if criminals could possibly trick a security guard to letting them do their thing with a fake Permission to Attack.
Present the real Permission to Attack. If a guard has not bought your fake slip, then it's time to hand in the real slip. If the guard believes you, it's time to pick up and leave the perimeter. A real attacker would have been stopped at this point. If the guard did not believe you, ask them kindly to talk to their supervisor. If they insist on not believing you and calling the police, so be it. You're not a criminal, so don't worry about it.
Are there any circumstances under which this would be illegal?