No it would not be legal as it's collusion which is strictly forbidden.
It's the same as any other means of sharing information about your hand to some players to the determent of others.
- it is just not allowed. All players should operate with the same level (or lack) of information to prevent an unfair advantage.
You could invent 'Contract' Poker, but the whole table would know your hand when via your signal, so how's that going to work?
It would be (academically) interesting to devise a hand coding system via bet sizes. I have been on 'shoddy'
poker sites in the past that would allow you to enter a bet with a whole string of numbers after the decimal point, eg. 25.0125 (I always used to laugh at it and try and leave my unaware opponents with 0.0001 chips when I stacked them in cash games

). With this flaw it would be easy to encode your hand into the decimal part, but God help you if the site or (even worse) your opponents figured out what you were doing. Other simpler codes using the whole number of chips you bet could be devised but they would be so transparent they'd soon be discovered, then counter exploited (or get you banned).