I don't really see why a leap to indentured servitude is necessary here. There are obviously many other ways of implementing a training relationship - see the other comments re. how it is done in Germany.
The point I'm making is that society as a whole is worse off if companies are too risk averse to hire and train juniors up to a certain level of quality. This results in too few people capable of doing a specific, presumably valuable, job well. The consequences of this are a society that underperforms it's true potential in the long run. In monetary terms, as you raise the question, that means that less taxable value is generated. So society as a whole pays the consequence.
Germany isn't exactly a huge centre of innovation these days or even remotely close to being a success story when it comes to software.
I do understand your overall point though and agree to a large extent, it just seems to me that this is primarily a natural outcome of workers having significantly more bargaining power than before. i.e. it makes little sense for companies to invest much into less experienced workers when they can't "force" them (directly or indirectly) to pay back all of those costs by working for depressed (i.e. compared to what companies which only hire experienced workers can pay) wages.
How can we bring this back without significantly reducing worker rights/bargaining power?
Government/etc. funded programmes might be an option but that would/should effectively be more of a reshaping of formal education to be more inline with teaching the specific practical skills/etc. that would allow workers to be immediately productive (not necessarily a bad thing but not quite the same).
OTH if tech mega-corporations continue growing at the same pace and consuming all competition we might end up in a situation where investing into junior/inexperienced workers will makes sense again because they wouldn't have any other choice but to stay and to work at the same company that hired them for the remainder of their career.
The point I'm making is that society as a whole is worse off if companies are too risk averse to hire and train juniors up to a certain level of quality. This results in too few people capable of doing a specific, presumably valuable, job well. The consequences of this are a society that underperforms it's true potential in the long run. In monetary terms, as you raise the question, that means that less taxable value is generated. So society as a whole pays the consequence.