GitHub Copilot Chat (which is part of Copilot) can change existing code. The UI is that you select some code, then tell it what you want. It returns a diff that you can accept or reject.
https://docs.github.com/en/copilot/github-copilot-chat/about...