How do I fork and edit a third-party package?

Yes you can do that. I’m also sometimes doing this when exploring usage of a package and modifying it this way. When everything is stable, I come back to the package and apply modifications if it is mine, or start discussing with the author if not.