Is there anyway to stop someone from seeing I’m online when I’m playing Minecraft?
If you go into the guide menu (or the Xbox Game Bar on Windows), and select your profile, you can change your online status from "Online" to "Appear Offline".
As the status name suggests, it makes you appear offline. Game time will still tick, but if anyone (friend or not) looks up your profile, they'll see you as offline, even if you're standing in front of them in-game.