Lucky you
Your panels are set up very advantageously to put in a generator transfer switch. All the loads you want to switch (but one) are already in a subpanel. This makes this super easy. It's almost like somebody planned it... Except the guy who put the pump circuit in the main panel did not get the memo.
You need to put a different transfer switch in between the two boxes. There are a couple ways to do this.
One is fit the subpanel with a manual interlock switch. This is a listed (offically tested) modification to the subpanel where it puts two breakers opposite from each other with a sliding plate so they can't both be on. Simple and cheap, and you may even be able to retrofit your existing panel. Must be thrown manually.
The other way is to pick a spot along the cable between the panels (or elsewhere if you don't mind rerouting cable), cut the cable, and insert the transfer switch inline. This will work with any kind of transfer switch, including automatic. You'll need to cut the cable on one side with enough slack to work, and the other side will be too short so you will have to replace that "half" of the run. So choose location and cut point very carefully to your advantage.
That one breaker in the wrong panel
The stuff you are imagining, you cannot do anything like that. In that approach, the options are break the law, backfeed the grid and kill linemen; or spend a king's ransom on more heavy cables than the underside of an NYC subway car, in a veritable Gordian knot of transfer switch wiring that nobody will be able to figure out after the fact. And the power company and inspector will absolutely hate it.
The right way is easy, if annoying: move the circuit to the subpanel. Extend the pump circuit, all wires, to the subpanel and land it on a double breaker, ground bar, and neutral if used. Do not continue to use the ground in the main panel, in fact if you make this splice inside the main panel, tape the ground wire with green tape to insulate it from the main panel. It's not the end of the world if it grounds accidentally, but grounds must go to the same panel the hots do.
I know that's a pain, but it's way less of a pain than anything else you could do legally.
Not room in the subpanel?
This happens a lot, some guy drove back from the subpanel store slapping himself on the back for saving $30... by buying barely enough spaces. Don't be that guy. You're going to need 6 right off the bat - 4 for the transfer switch and 2 for the well pump.
Worst case you may need to replace the subpanel, and fortujately that is DIY-possible because you can entirely shut off the panel at the main breaker. Also a great time to be looking for transfer switch friendly panels if you want to go that way. Don't scrimp - slap yourself on the back for buying twice as many spaces as you need today. The bigger panels often come with "bonus breakers" which save you some money too.
Best Answer
You need to de-energize the wiring
I realize you're very cocksure, but...
Really, really, you need to de-energize the wiring using the normal methods for doing that in your country.
Absolutely no one on this forum is going to counsel you to do that work "live", even with the much more docile American 120V-to-ground (2 or 3 phases).
Here are the real facts about arc flash.
https://www.youtube.com/watch?v=6hpE5LYj-CY
I recognize this panel as being a common American industrial 480V board. (277V per leg). In America this is considered "industrial-scary" and is treated with grave respect.
However your voltage is only 18% less than this.
You may say "But that's so much more current than I deal with" - nope, when you do stuff like this, the current is limited only by the wires. US power companies guarantee that the wires will limit current to 25,000 amps or 10,000 amps. Even if we assume yours limits to 5000 amps, do you really want to mess with 5000 amps?
This just doesn't work. Pull the meter.