If an LH flight segment has earned miles in UA Mileage Plus, then the reconcilliation file between the carriers is annotated accordingly and the standard retro claim request for Miles&More will fail - regardless of what your boarding pass says.
You're facing a tedious manual intervention process to get UA to remove the miles from the account, certify that in writing, so that LH can then manually go and retro-credit the miles to your M&M account. It can be done, but it's a lot of effort so not sure if it's worth it for you.