I looked into the same problem several years ago. The best I came up with was small solenoids. You can get some for around $1-2 on Aliexpress.
You still have to get somewhat creative though:
- the smallest are larger than you'd like (if memory serves, the smallest I found were something like an 8x10mm footprint).
- you're only supposed to activate them for a few seconds at a time.
- their holding power is minimal
For the timing and holding power situation, what I came up with was using a mechanism about like a click-type ballpoint pen. Click it once, and it goes up and locks in place. Click again, and it can drop back down.
The click-click mechanism gets you load bearing that's limited by the materials you use rather than the solenoid itself, and reduces power draw/heat dissipation requirements, because you're only activating a solenoid to change state, not to hold a position.
That leads to one further problem though: most of the smallest solenoids pull when activated, but for the click-click mechanism, you'd usually prefer that it push when activated. For the prototype I built, I ended up mounting the solenoids "backwards", and using a U-shaped pin (but that's not the only possibility).
To increase the pin density, you can mount the solenoids at two different depths, so you have one set that's close to the front face, and another behind them, with longer pins that extend between the "front" solenoids. With some care, I think it's possible to manage something like 5x6mm pin spacing this way.
Example Solenoid
https://www.aliexpress.us/item/3256804955523192.html?spm=a2g0o.ppclist.product.216.484944nV44nVa1&pdp_npi=2%40dis%21USD%21%241.56%21%241.56%21%21%21%21%21%4021059dbe16854590518697577edae6%2112000031829409597%21btf&_t=pvid%3Aaaeb16e7-e06b-47c0-97db-10ca19d89f3f&afTraceInfo=1005005141837944__pc__pcBridgePPC__xxxxxx__1685459052&gatewayAdapt=glo2usa