Well, as we all know Shanks has a scar on his left eye which is given to him by Marshall D. Teach aka Blackbeard; the scar was absent on Shanks when he was part of Roger crew.
When Shanks visited Luffy at Foosha Village he had scar. So he received the scar from Teach during the period between Roger’s execution and the visit to the Foosha Village.
Here’s my theory. I’m going to start with the devil fruit which Shanks had (Gomu Gomu no Mi) and the devil fruit which Teach wanted (Yami Yami no Mi). Both the devil fruits seem to look similar for color and design. So it’s safe to assume that one can get confused on recognizing them. And if you are as desperate as Teach well you will.
Now, when Shanks entered Whitebeard’s ship Moby Dick, the reactions from various crew members were like they were meeting Shanks as Yonko for the 1st time, those who fainted on his arrival. Even Shanks’ conversation with Marco “so, you are 1st Division Commander Phoenix Marco” states that Shanks and Whitebeard never clashed as “Yonkos”.
So how and when did Teach gave the scar to Shanks??
I think that Shanks (before being a Yonko) had found a devil fruit Gomu Gomu no Mi from a certain pirate crew somewhere in the Grand Line.
And Teach was already after Gomu Gomu no Mi mistaking it for Yami Yami no Mi, which he has seen in the book of devil fruits. So when Teach arrived, he found out that the fruit was already stolen by Shanks. So he planned to get the devil fruit from Shanks and we know how evil planner Teach is.
He joined the crew of Shanks(remember Teach wasn’t an infamous pirate then, he always leaved in shadow of Whitebeard). He managed to infiltrate the Red Haired Pirates and waited for his opportunity, as soon as he got his hands on the devil fruit, he was caught by Shanks and at the same time he realised that devil fruit wasn’t the Yami Yami no Mi. Now, in order to flee, Teach tried to fool Shanks in a meaningless talk, while attacked Shanks when his guard was down giving him a bloody scar on eye with his claw and managed to flee from there.
*Theory by blaze