I have a similar situation to the OP. I bought a ticket for a LX-operated flight GRU/ZRH but LH-marketed (flight number starts with LH). I knew that I wouldn't be able to use UA miles for Star Alliance upgrades because the policy is clear ("Codeshare flights not eligible."). The reason why I bought the ticket anyway was that the same flight in Y was €400 cheaper with the LH number than the LX number.
My question is: are you aware of calling LH and they change the number of the flight to a non-code-share one so I can use the SA upgrade? I know this is a long-shot, but asking it because I'm aware in United they can sort it out some cases with LH and NH (not with LX though).