You should be able to call addMark with the extent of the old mark and the new attributes. Since you can’t have two link marks on the same content, that’ll automatically replace the previous link mark.
Hey I am using tiptap(which is built on top of ProseMirror), could you maybe share a code example for removing an existing markup and adding it with update attribute. It is a custom markup.