Rendering multi-layer EXR using File Output node in Python
In order to change the path of the output node you would have to set OutputNode.base_path. Make sure RenderSettings.use_compositing as well as Scene.use_nodes is enabled. Tested against the following node setup successfully:

import bpy, os

C = bpy.context

# Enable Post Processing and Use Nodes
C.scene.render.use_compositing = True
C.scene.use_nodes = True

# Get the File Output Node by name
out = C.scene.node_tree.nodes.get(&quot;File Output&quot;)

if out:
    # Set the output path of the node based 
    # on the regular path of the output
    out_dir = os.path.dirname(C.scene.render.filepath)
    out.base_path = os.path.join(out_dir, &quot;multilayer_&quot;)
    # Call the render operator
    bpy.ops.render.render(write_still=True)

Related: How to properly connect the Denoise node in Compositor?

Rendering in headless mode works as well:
./Blender -b file.blend -P script.py


Layer Contact Sheet node in Natron