Do I need to change the git url of a dependency to my own repo and set the branch, or is there some other way to do this? Or should I only make a companion when the pr is merged?
There are more detailed instructions in the Substrate contribution guide:
To create a companion to a Substrate PR, you must create Polkadot and Cumulus PRs which would fix any changes caused by the Substrate PR (for example removing or adding some function to the weight files of a module).
Once you have created those companion PRs, you should include them in your Substrate pull request description as:
polkadot companion: <link> cumulus companion: <link>
For example: https://github.com/paritytech/substrate/pull/9018
In the companion process, you should not expect that the PRs to Polkadot or Cumulus compile in the pull requests to those repos. This would not be possible since the Substrate PR has not yet been merged.
Instead, you should look at the Substrate PR to see that the CI/CD checks "polkadot-companion" and "cumulus-companion".
If this works, then you are all good to go, and our merge bot will be able to merge the Substrate PR, then the subsequent Polkadot and Cumulus PR right after.