shorting a remote control pushbutton with GPIO and a transistor
To eliminate any possibility of surprise, and to generally make things more robust, I'd suggest using an optocoupler like 4N25.







simulate this circuit &ndash; Schematic created using CircuitLab

With this arrangement, you don't need to worry about how to combine the separate grounds of the two systems, because their grounds simply aren't connected. Also, if there's a problem on either end, the optocoupler may isolate the fault to one side, and is cheap to replace, where a Raspberry Pi or garage remote is not.

Depending on exactly what the garage remote is, you may need to add another transistor to handle additional current, because the 4N25 has an absolute maximum of 50mA. Q1 is one way to do that, and general PNP transistor you can find will work in this application. This arrangement formed by Q1 and the output transistor of the 4N25 is called a Sziklai pair.

One potential disadvantage of this solution is that when the transistor is on, the remote (represented by U1 here) will see only about \$8.2V\$, where it would have seen the full \$9V\$ had these transistors been replaced with a mechanical switch. This is because you lose \$0.6V\$ from the emitter-base drop of Q1, and another \$0.2V\$ from the collector-emitter drop of the 4N25. However, I doubt this will be a problem in practice.