In case when player2ID is constant (not variable)
If you haven't autoloaded
Globals.gd, autoload it. After autoloaded it, set class name on the top of the script like this.
const player2ID = 1
Now you can access that as global scope variable.
In case player2ID is variable...
It's possible if only node that containing
Globals.gd script and node that containing script that has
_on_player_connected(id) are instanced in the Scene.get reference from one node to another node and you can set/get the value.