It is possible to programmatically change forwarding rules for an extension. However, to do so you will need to use the Call Control API.
Unfortunately, this is a fairly complicated issue because (1) no documentation is available for the API, (2) the API only responds to requests from local host and 3CX does not want you to install your applications on the 3CX server, and (3) the API only permits one simultaneous request to the API, so you can only have one 3rd party application working with the API at a time.