I've definitely seen this pop up more in the last year or so. There's actually a real cost difference, though restaurants probably lean into it more than they need to. When you eat at their place, they're covering table space, utilities, staff to bus and serve you, water, dishwashing - basically all the overhead that comes with running a dining room. Takeout cuts a lot of that out. They still need to box the food and handle the order, but there's no table turnover cost or server labor per customer.
The thing is, most restaurants probably could absorb dine-in costs into pricing without the gap being this noticeable. What's really happening is they're using it as a lever - they want to push people toward sitting down because it typically means higher check averages (drinks, desserts, sides) and better table economics. Takeout orders come in, tie up kitchen time, and customers just leave. So yeah, there's a legitimate cost argument, but the markup also serves as a soft incentive. Some places just price based on what they think people will pay for each format, not strict math on actual costs.