Once you’ve modified the object in memory (record/dictionary of keyValues, or array of such records/dictionaries), you can write that transformed object back out to a plist, e.g. with something like writePlist() here: Reading and writing plists from Execute Script actions
(where ‘plist’ means a kmMacros file in this case, of course)