I did it on a TT bike without internal wire routing about 10 years ago. You have to be a bit old school and have it running externally but there is specific wire tape for routing and attaching it down the frame. It’s not elegant but it works and has lasted well.
The battery normally lives in the seat post, Make some kind of shim so it’s a snug fit.
The junction box is usually outside the bottom bracket shell (inside the frame) and the cables run from the junction box round the bottom bracket shell, one to the batter & the other to the rear mech.
Depends also which version of Di2 you have as the newest ones have wireless shifers.
“Dirk Bockel’s 2012 Blue Triad SL is covered with unique modifications. He is the only athlete racing the 2012 Triad SL, and this version is 200 grams lighter than the 2011 iteration. He rides Shimano Dura-Ace Di2 components but instead of mounting the battery and routing the wires on the outside of the frame, Bockel hides the extra lengths of wire almost entirely within the frame. The Traid SL doesn’t have integrated Di2 routing, so Bockel’s frame was modified for this purpose. The aerobar spacer has a small opening that leads to the open space inside the nose cone. The shifter wires pass through the aerobar into the nose cone and finally exit the frame on the side of the cone through the hole in the spacer. The extraneous wire is shielded within the nose cone. His battery is jammed up between his saddle rails and is completely shielded by the seatpost, his rear bottle cage and saddle. The wire goes directly from the battery into the rear of the modified seat tube. The standard Triad SL seatpost has two saddle mount positions, one forward and one rearward. Bockel uses the forward position, so Blue sawed the carbon that creates the rear mount off the seatpost and the wire from the battery passes into the post where the rear mount is usually located. The wire passes through the frame to both the front and rear derailleurs and up to the control box, positioned directly behind the stem.”