I guess the answer is yes they can. But not the best option. They need at least 2x2x4 and bigger would be better. They like to get about and check things out. That would be too small for them to move comfortably.
They can fit in any size enclosure and survive if you have the correct temps and lighting. The question is what quality of life are you providing with the size habitat you are providing?. They will grow, regardless of the size of the cage. 2 X 2 X 4 is the standard recommendation because it is about the tallest ready made cage out there without doing a custom build.
I think losing a foot of height but gaining 2 feet horizontally is a good compromise. Chameleons like height, yes, but given the chance they would rather walk horizontally vs. Vertically. So I think that sounds good.
i have this in the medium.sullys still small atm although he spends most of his time out of his home lol.but im upgrading to the large in 5/6 months.ive seen it and its a really nice size.