Obviously there are no guarantees, but usually if you do well enough as an undergrad at a college in the range we are talking about, you can go to a highly-regarded Masters program. Getting a funded position in a top PhD program is a whole other thing (and getting even more so), but a Masters you would pay for is typically more accessible.
Of course if you don’t do as well as you hoped in college, or change majors for other reasons, or change career plans generally, that will lead to a different plan. But that would also be true if you choose the “prestigious”/expensive college–if you don’t do as well as you hope, change your major, change your career plans, or so on, your original “ROI” assumptions may be invalidated.
I will say I think one of the reasons to choose a generally good college is precisely so that if you do change plans, for any reason, it will still be likely to support your new plan. But as I like to point out, if you choose to go deeply into debt in order to attend some specific college, then it can really ruin that concept, as you may no longer feel free to choose any other path that does not promise that big payoff you were counting on to justify that expense (or at least not soon enough to service that debt).
So the cold reality is a lot of people who rack up large student debt end up in educational and career paths they don’t like. But they feel trapped by the need to service all that debt. And I strongly feel college should not do that to you, meaning college should give you many options, not force you into a specific path.