To modify it, I think you should load the resource with
load. This gives you a
SpriteFrames resource. If it's already loaded (which is very likely if your sprite is in an open scene), then Godot will just give you the reference to it.
Then modify the resource normally by using the
SpriteFrames API: https://docs.godotengine.org/en/3.1/classes/class_spriteframes.html
Once you're done, you may want to save the changes. But there is a catch:
You could simply start by saving the resource with
ResourceSaver.save(sprite_frames.resource_path, resource). But that will only work if the resource has already been saved as a file before. Remember resources can exist embedded in scenes or even other resources. Also, that's not undoable, and Godot won't even know if your project has changed. That might be fine, but in reality, it's rarely what needs to happen and can lead to annoying usability issues.
So consider this: if your plugin gets to modify a
SpriteFrames resource, it very often means the user has a
AnimatedSprite using it already in an open scene, or has selected one somehow, which means the resource is already loaded.
When Godot saves a scene, it saves all modified resources with it automatically, and it puts them in correct locations (file, scene, whatever), which means you don't need to save the resource yourself, or even worry about where it is. You only need to tell Godot it was modified.
How to tell that?
I had the same issue with my plugin before, and I'm not sure if that's the onlyway, but I came to realize
UndoRedo was the key. Whatever you are doing to the resource, try to modify it through the
UndoRedo instance of the editor.