WARNING: Major spoilers for Avengers: Endgame.
Captain Marvel disappears for an oddly-long portion of Captain Marvel (Brie Larson). The newly introduced female hero in the Marvel Cinematic Universe only has a minor role in Avengers: Endgame, so where was she during the majority of the film?
In the lead up to Avengers: Endgame, it appeared that Captain Marvel was going to be a major force in favor of the Avengers. Her logo was shown in the Captain Marvel's mid-credits scene, audiences got to see Carol arriving back on Earth looking for her friend. This set Captain Marvel to play a key role in Endgame from the start.
Indeed, it is Captain Marvel who early on in Avengers: Endgame sets her sight on finding and killing Thanos, and she (somewhat reluctantly) agrees to work with the other heroes to accomplish this. The team goes to Thanos' garden, find out the Infinity Stones were destroyed, and watch as Thor decapitates the Mad Titan. Avengers: Endgame promptly jumps five years in the future, where we learn that Captain Marvel is no longer on Earth and she stays in outer space all the way until the film's climactic battle. So, what was she doing instead of helping the Avengers travel through time?
Well, we do know that Captain Marvel was still working with the Avengers in some way during this time. She appeared via a hologram for a brief meeting with Black Widow, Nebula, Rocket, Okoye, and War Machine to discuss what was happening in the universe. The new look Carol (with a short hair cut and new costume design) is asked if she will be back on Earth anytime soon, which she says is unlikely due to her current tasks. She will instead stay in space to do missions of her own and patrol the galaxy, which ultimately got in the way of her helping the team in their missions.
Unfortunately, we do not know what exactly Captain Marvel is up to during Avengers: Endgame. Since she previously where Carol Danvers was between 1995 and 2018, so there are countless other allies she could've made and is helping protect after the snap. That said, Captain Marvel is also likely looking to help anyone who is need of it during this time of crisis, possibly even ending other wars that could be born out of the chaos.
Even though it is not explicitly revealed what Captain Marvel is doing in space during the events of Avengers: Endgame, she does at least (conveniently) return to help out during the Captain Marvel 2, if it needs to be shown at all.