+1 to the M1 mini suggestion.
eGPU: These are not currently supported with M1 macs (one of the few M1 flaws). eGpus aren't Apple supported with 2011 iMacs either, but it is possible to use one with a 2011 iMacs using third party software. However eGPU enclosures are kinda of expensive, running one over Thunderbolt 1 adds a performance penalty, and they require an external display for best results. If you are buying an external display anyway why not get an M1 mini?
Graphics cards: Don't get a GTX 765M. Those are MXM-B cards which are too big and power hungry for a 21.5". Granted the 765 is on the low end for TDP, but that is still an unnecessary risk/complication to ridiculously risky/complicated upgrade. A 21.5" wants an MXM-A GPU that has custom iMac firmware flashed (an iMac friendly vbios is required for the internal display to work). In 2019-2020 a couple amateurs wrote custom mac vbios files for the Quadro K1100M, and K2100M, so those are basically the only alternatives to an Apple card. Naturally those cards are now expensive, and being old and used at high risk of arriving dead on arrival.
So do yourself a favor and get the M1 mini (or a new iMac). Spending a couple hundred £ to squeeze extra VRAM into a 2011 iMac that will be obsolete in 2-3 years is not a good long term investment and could backfire spectacularly if you make any mistakes or cut corners on your research.