In Maya and C4D, we have this color option of a specific object. Basically, change it to red and the control curve looks red in the viewport. Done deal.
Is there the same setting in Blender?
Whenever I tried googling the matter, the solutions consist of making material. I think material is an overkill since I don’t really render the control curves.
Your picture looks a lot like custom shape bones. Assigning them to bone groups can assign them color.
If you haven’t looked into custom bone shapes, you should. I’m not sure of your end goal, but you might be duplicating existing functionality in your planned script.