Rename a Collection using Python? Is there a way to access a collection's name other than through bpy.context so it can be renamed?
Collections are ID objects
In blender any ID object is stored in bpy.data  Objects in bpy.data.objects meshes in bpy.data.meshes collections in bpy.data.collections etc etc
To rename a collection named &quot;Bob&quot; to &quot;Frank&quot;
import bpy

col = bpy.data.collections.get(&quot;Bob&quot;)
if col:
    col.name = &quot;Frank&quot;

Note if there is already a collection named &quot;Frank&quot; then numbers are appended &quot;Frank.001&quot;... as per unique naming convention.
Related
How to rename objects with python?