It's true that our personality is largely shaped by our experiences, but that's not the same as saying that your memories are your personality. So just because someone has all of your knowledge or even your memories doesn't mean they'll think and behave exactly like you.
A simple example of this are your past selves. Your 16-year-old self had pretty much all of the memories that your 6-year-old self had, but did you behave exactly the same at age 16 as you did when you were 6? What about now? Do you have exactly the same desires/values/perspectives now as you did when you were 16? If not, then clearly someone can possess the same memories and even retain all superficial personality traits (language patterns, mannerisms, favorite foods, etc.) but still behave differently in more fundamental ways.
Another example of this are beta-blocker drugs that are used to treat PTSD. Beta-blockers don't erase memories of trauma, but when used during recall of traumatic memories, they can dull the emotional associations you have with the event, changing the way you perceive those memories in the future and thus alter how your behavior is affected by those same memories.
So I see no reason why the John Connor replicant can't have all of John Connor's knowledge and memories and be able to act like John Connor but still have his allegiance switched from the Resistance to Skynet.
Likewise, they could have just scanned Connor's brain for his knowledge/memories while the machine-phase matter ate and replaced his body, effectively killing him while creating a T-3000 that looked just like him and could behave like him using the scanned memories but was still programmed to work for Skynet.