I would subtly manipulate the dialog so that your main character can have scenes where the imaginary character and a real character are both talking and it seems like they are having the same conversation, but not really. For example, the imaginary character asks a question, with the next snip of the real character's dialog responding with what seems like a correct response, but not specifically an answer to a question. If Sarah is your hero, Alice is your imagined character, and Dave is a real character:
Alice: I bet Dave's favorite animal is weird. Probably a Platypus.
Dave: I like polar bears.
Dave: Yeah. They're cool.
Alice: Ooh. That pun hurt.
Sarah: Platypi have nothing on Polar Bears?
Dave: I'm not sure they're even real. I think someone is making them up.
Alice: Now that's a twist.
Note how Alice is responding to Dave, but Dave is not responding to Alice. His initial statement is an unprompted announcement of his favorite animal (maybe they're both at a zoo or trying to make small talk and get to know each other), but his first statement doesn't mention the platypus at all, he doesn't respond to Alice's comment on the pun, and the first time he states his opinion on the platypus is after Sarah brings it up. While the first two lines certainly look like a conversation between Alice and Dave, it could be that Sarah and Dave have the same idea of a good icebreaker conversation in this situation and Dave makes the statement while Sarah/Alice are still thinking it over ("I was just thinking the same thing!").
The final line contains both an obvious and subtle joke. Alice reacts to Dave's faux conspiracy theory with a standard meme. This both alludes to M. Night Shamalyan and his famous fictional example I was going to suggest and lightly based the scene on Sixth Sense which has a slightly different twist (one of two good films of his). But it becomes funnier on a "second read" where the audience is aware of the twist of your story. Alice isn't just making casual snark, but foreshadowing the true nature of her character in a way that doesn't spoil it if you didn't know.
Incidentally, the Sixth Sense makes a lot of use of scenes where characters will talk at each other, not with each other. It looks like they are having conversations, but if you actually pick apart these dialogs, they aren't having the conversation or have the same understanding about the discussions. All act perfectly natural given the context of what they think is happening, and all their assumptions about what is happening are valid.