Is it Possible to Program AntMiner S9 or Other ASIC Miners?
Yes it is possible. To do so, you will need to modify the firmware and install your own firmware onto the S9. The source code for the firmware is available on Github. The firmware is really a lightweight operating system and includes software such as CGMiner preinstalled. Those preinstalled software are probably what you will need to modify, and those are likely written in C/C++.

Since what you want to modify effects the data that is hashed, it should not effect the hashrate at all.