While it is not difficult to parse the JSON-formatted extra headers in Python, doing so to set or replace a single extra header is cumbersome and likely slow for what should be a simple call.
libmseed contains mseh_set_ptr_r() that sets (or replaces) values in the extra headers of a parsed record identified as a JSON Pointer. This can be used to implement, e.g., MS3Record.update_extra_header(). The supplied header value type can be detected for specification to the library function, including JSON Merge Patch capability for complex updates.