This has been written about a lot in science fiction and AI research, and it was touched on in TNG's "Booby Trap" with the Leah Brahms hologram. In theory, if you program a computer with all available records of a person's speech or writings, things that are known about their lives and interests, and so on, it's possible to construct a simulation that can predict how they would behave or react in a given situation. The way websites track our activity and use it to tailor advertising to our presumed interests is a crude version of this kind of personality modeling. There are also computer programs that can simulate a famous author's writing style based on an analysis of their body of work. We have those today, so just imagine how much more advanced it could get in the future. In principle, the more data you gather about a person, the more accurately their personality can be simulated.
One example of this idea is in a novel named Blue Remembered Earth by Alastair Reynolds. The story was catalyzed by the recent death of the matriarch of the main characters' family, and one of the characters had built a personality model of the matriarch based on all available records, assembled over a lifetime in a society with nearly ubiquitous communication and monitoring, so that there was a huge amount of data available. And they used the simulated matriarch to help them figure out what the real one had hidden away. The simulated person didn't know the things the real one had kept out of the public record, but otherwise she was so convincing that the main characters sometimes forgot she wasn't the real deal.
When you think about it, it's not that different from what an actor does when learning how to impersonate a real person, or what any of us do when we predict what our friends or family members would probably do in a given situation. The human brain is a very powerful simulation engine, and we all build mental models of the people we know and use them to predict their probable responses. And the better we know them, the more accurate our models become. Although there's always a margin for error (as "Galaxy's Child" made clear).