If you are trying to manually define the Z-order, you can set the z_index using something like node.z_index = value for Node2D-based nodes. You may also want to set z_as_relative to false, depending on how your scene is setup and the needs of the project.
So for something like the example in the opening post, something like this might work:
z_index = -round(global_position.x + global_position.y)
One thing to note is that the Z index has to be an integer, so you'll likely want to round the value to the nearest pixel if you are using position-based Z indexing.