Yes, optical illusions can be photographed. Optical illusion photography is an impression created that is not appropriate to reality. This type of photograph can be taken naturally without the use of post photo production service or other photo manipulation techniques.
The human eye is weak at judging size and depth from a distance that is why it is easy to make optical illusion even without editing the photos. Examples I have seen: photo of someone holding the sun and photo of someone standing an touching the peak of one of the seven pyramids.
To make an optical illusion photo you need to understand the background you are working with, depth and size of the objects.
In this modern age, it is more possible to have optical illusions photographed. The first optical illusions date back a long time ago maybe you have seen a photo of a woman carrying 5 people in her palm. Optical illusion photography makes the people look closer at the photo that is not possible in reality just like the example given.
To have a successful optical illusion photo, you must know the depth and space of your object to its background. You can always grab your camera, go outside, look around you where you can try practicing shooting optical illusion photography. Take a photo of you holding the sun while it is setting down when you have the chance.