Remove SRAM Guide with internal routing
For the most part you can just disconnect the lever end, taking off the olive but leaving the barb, shake off any loose drops and pull it through. The system is closed on the other end so it won't come spilling out.

Two other ways if you want or need to do something unusual: disconnect the hose from the lever, attach a bottle to the hose to connect the fluid, position the bike so gravity will do the work for you, open the bleed port on the caliper, and let it sit for a while as all the fluid drips out. Shake it to get the last droplets out before pulling through. You could also blow air through the hose first (not with your mouth) if you wanted to be faster or cleaner perhaps.

Alternatively, cut off the hose above the barb and find some kind of round thing to shove up there to plug it, then pull it through.