I have found this thread and several other threads but nothing with any legit answers. We can somewhat select a collection using for example this script that "selects" the one at index 2:
collections = bpy.context.view_layer.layer_collection.children bpy.context.view_layer.active_layer_collection = collections
But that doesn't fully select the collection as can be seen below. It is not blue in highlight. This can be proven when you press F2 in the Outliner, it will attempt to rename the one in blue highlight instead of the supposedly newly "selected" collection.
When I click a collection I see the command
bpy.ops.outliner.item_activate(deselect_all=True) but adding this to the script doesn't help. How do you fully select a collection with python or is this even possible? The solution for this question will help solve this thread.