Being non-expert in patch array antennas, I can't answer the "how".
Nevertheless, X-band antennas in this range of gain and compatible in form factor to 6U Cubesats are commercially available.
Here is an example of an 8x4. The datasheet says it has 20.7-21 dBi and it measures 20 cm x 10 cm x 0.3 cm., weight 90 g.
Of course, the beam pattern cannot ...