Second, open the shared parameter file for writing (it’s just a text file) and add the parameter to it. That same script has functions that find the current shared parameter file and one writes files in the shared parameter format so you should be able to cut and paste the necessary bits together to suit your purposes.
File locking might be a problem, with Revit and pyRevit reading and writing the same file. Also, the shared parameter groups are not stored in Revit which is probably why the export button uses a default “exported” group, you’ll need to see if the group name you want to use is already there and if not add it, but that is not as easy as simply appending another parameter at the end of the file.