You can add a transient suffix with the following line of code:
```
(transient-insert-suffix 'magit-dispatch (kbd "h") '("G" "grep" counsel-projectile-rg))
```
read the docstring of `transient-insert-suffix` for an explanation.

Here I am adding the command `counsel-projectile-rg`, which I use myself for this case (well actually I am just using the Spacemacs key-sequence `SPC /`), and which I can really recommend. There are equally good alternatives for [helm](https://emacs-helm.github.io/helm/), [consult](https://elpa.gnu.org/devel/consult.html) and probably more... also for other backends like `grep`, `ag` etc...