I don't see any way this could be done safely, to code, etc.
Problem being there's no way to interlock the MAIN and the Generator if they are on different panels. Without an interlock, it's quite simply not safe (and in a more nuanced view, if the power company becomes aware of it you may not get your power turned back on - they REALLY don't like that.) The fact that you say you will turn it off is just not good enough. If the service folks are in your area restoring power and they hear a generator running, they very often WILL come check.
It IS possible to have a generator input to the main panel, if the panel manufacturer has an interlock kit for the purpose - I have one. It is not physically possible for the MAIN and the Generator to both be turned on at the same time. The only way you could have it go into the sub-panel would be if the sub-panel was interlocked to disconnect from the main panel, so you absolutely cannot feed the main from the sub, no way, no how.
The generator is portable - when you need it, move it, and provide enough cord from a proper interlocked input on the main panel to connect to it. Or, run new wire all the way to where you want it outside the garage.