So I think you will need to do something like watching for the connection error, using a catch node, using that to trigger a flow to regen the token which you capture to a flow context variable.
Hmm, but then you would have to restart the websocket and not sure how to do that.
Actual environment variables are only read when Node-RED starts. However, Node-RED has extended the idea of env variables and allows you to set them in its tabs, groups and sub-flows. I've not tried this but perhaps having the main websocket flow and the catch flow in the same group would let you update the env variable set in the group which the websocket node would use.
This is just speculation though - I've no idea how the websocket node would react.
Thankfully, Node-RED generally gives you alternatives. In this case, the alternatives would either be to create your own websocket custom node (obviously check the flows site first to see if someone already has done this) or possibly to use a function node with a locally required websocket library. Obviously both of these options will require a reasonable amount of JavaScript progamming.