I've managed 32, in the pictures below I built a board that does 30 - you need about 2K+ scans/second to avoid missing a transition, but that's not too hard to achieve.
Additionally, since encoders have the "common" pin between A and B, you need 2 matrix slots in the same row (if diodes are oriented col2row) or the same or the same column (if diodes are oriented row2col).
Aside from that, it's pretty straightforward.
IMG_7584_1080.mp4 (29495 kB - downloaded 7 times.)
I have a PR to QMK to show how it's done, visible at
https://github.com/qmk/qmk_firmware/pull/23700 if you care.