How do I add extra bones to rigify armature?
You can add new bones without modifying the script.

Just create new bones or duplicate existing bones in the MetaRig, before generating the rig, orient and parent to the bone you want them to follow, then, in Pose mode, set the rig_type in the bone options.

The rig type determines how rigify handles the new bones. Wether it will create controls, etc.

Video demo from DanPro