It works but only in 1 situation which is going to be very rare.
The correct way to read the rules is:
Sunlight Sensitivity
You have disadvantage [on attack rolls] and [on
Wisdom (Perception) checks that rely on sight] when [you], [the target of
your attack], or [whatever you are trying to perceive] is in direct
sunlight.
To reiterate, when any of the following is true:
- You are in direct sunlight
- The target of your attack is in direct sunlight
- Whatever you are trying to perceive is in direct sunlight
You have disadvantage on:
- attack rolls
- Wisdom (Perception) checks that rely on sight
So, your plan will work if you are not in direct sun light, your target is in direct sun light, and the target is not more than 10 feet away.
It seems to me that this is not a common situation. You are going to have to be very careful in positioning yourself on the edge of shadows. I would suggest it is more fruitful to take a step back and have your target walk into the shadows with you.
Why rules lawyering this doesn't work
Your argument hinges on trying to make a very strange reading of the text:
You have disadvantage on [Attack rolls and on Wisdom (Perception) checks] that rely on sight
While this is close to being grammatically correct, common sense dictates this is not a valid reading.
The second problem is the assumption that Sunlight Sensitivity is about light shining in your eyes, but that isn't supported by the rules.
Invalid reading
Firstly, "Wisdom (Perception) checks that rely on X" is a common phrase in the rules, showing up many times:
Eagle: Keen Sight. The eagle has advantage on Wisdom (Perception) checks that rely on sight.
Panther: Keen Smell. The panther has advantage on Wisdom (Perception) checks that rely on smell.
Killer Whale: Keen Hearing. The whale has advantage on Wisdom (Perception) checks that rely on hearing.
Jackal: Keen Hearing and Smell. The jackal has advantage on Wisdom (Perception) checks that rely on hearing or smell.
The list goes on; cats, cloud giants, weasels, werebears, owls, bats, rats, etc. There are dozens of examples.
How many examples are there of "Attack Rolls that rely on X"? None. None in the entire rules, besides potentially this example.
By itself this is not conclusive, but this is a huge red flag. We are discarding a common phrase that appears countless times, and instead relying on an interpretation that is unique. This goes against common sense and the way we normally read the rules.
Your DM will likely not accept this grammatical gymnastics purely on the grounds that it is just word games.
It is also not particularly grammatically correct. If this was the intended meaning you would say:
You have disadvantage on Attack rolls and Wisdom (Perception) checks that rely on sight
Notice I have dropped the second "on". This is an adverb which connects the verb phrase "have disadvantage" to the objects of the sentences "attack rolls" and "Wisdom (Perception) checks that rely on sight". Without it we have one object; "Attack rolls and Wisdom (Perception) checks that rely on sight". While you could argue that WotC simply made a grammatical error in including the second "on" (which can absolutely happen), this just another hurdle you need to overcome when convincing your DM.
Unsubstantiated assumptions about what sunlight sensitivity is
There is an assumption that the disadvantage on attack rolls must be because light is shining in the Duergar's eyes and that simply closing your eyes mitigates the penalty. While the description of the Duergar (monster) does mention their sensitive eyes, the description of Sunlight Sensitivity does not. Moreover, it specifically says:
You have disadvantage on attack rolls and on Wisdom (Perception)
checks that rely on sight when you, the target of your attack, or
whatever you are trying to perceive is in direct sunlight.
Imagine your foot is in sun light, how will closing your eyes change that? There is no reason to assume that sunlight sensitivity is purely about your eyes when the rules explicitly state that merely being in sunlight is enough to incur a penalty.
This is where the manipulation dies unfortunately. The rules are explicit, being in sunlight is enough to impose disadvantage.
Together these flaws can only be overcome with circular logic; if you assume that Sunlight Sensitivity is about sun being too bright for the Duergar's eyes, then you can twist the rules to suit your purpose and conveniently ignore all the evidence to the contrary. This is NOT the way that the rules should be read, you should NOT read the rules with intent to prove a point.