The primary cost is time, and it often makes sense to spend a lot of money to avoid wasting time.Isn’t “lock-in” a bit of hyperbole? What’s the time and money you refer to specifically?
For example, if I was looking to upgrade my iMac today, I would have to buy a Mac Pro, because the Mac Studio does not support enough RAM to be worth upgrading to. But the Mac Pro is expensive, and I would seriously consider switching to Windows or Linux.
Unfortunately I'm a very casual Windows user these days. Windows 2000 was the last version I understood well enough for my work as a researcher / developer. Buying a Mac Pro might be cheaper than learning to use Windows properly, and Linux would probably be a better choice.
Apps are another source of trouble. Many are not cross-platform, and you would have to find replacements for them, spend time to learn them, and maybe even pay some money. Apps bought from platform-specific app stores are the worst, because you often have to buy them again if you switch platforms. (I learned to avoid the Mac App Store a decade ago when I lost access to some apps after moving to a new country. For a year or so, Apple didn't even allow me to upgrade macOS for some stupid bureaucratic reasons.)
New apps may not always support the same file formats as the old ones they replace. When that happens, you have to figure out what to do with old data.
Backup solutions are often platform-specific. If you switch platforms, you may have to rethink your backups and maybe even buy some new software/hardware.
Cloud services don't always work that well outside their preferred platforms, and you may have to replace them as well. The ones integrated into the OS, such as iCloud and OneDrive, are among the worst offenders, which is why I try to avoid them.
Peripherals and their drivers often cause issues in Linux, and sometimes the easiest solution is buying new ones. The situation is better in Windows – at least if you don't buy monitors from Apple.