Write you own node_utils.js and socketio.js and start it instead of the ones built by frappe. You can try to hack up something to import and extend existing js files instead of full copy-paste.
Changes will be needed in :
- For manual production setup: supervisor.conf, change the
node socketio.jspart - For dev setup: Procfile
- For container setup: replace image of websocket / frappe-socketio service with your own image.
Another alternative is to add additional nodejs app and reverse proxy it: How Add nodejs App to frappe & bench? - #5 by revant_one.