Generalizing heavily, I think layoff risks looks something like this (from most risky to least risky):
1. Startups in an immediate or medium-term funding crunch. Standards to raise money are much higher now than they were in the recent past, so a lot of companies will likely go bust if they don't trim expenses aggressively. This includes a lot of companies that look relatively legitimate, have users, have nice websites, successful raised multiple times in the past, etc. If you ask them, they will never tell you they are having trouble raising, so you have to do your own research to form an opinion of their funding status.
2. BigCos under pressure from shareholders to grow profitability due to rising interest rates and competition for investor dollars. They have plenty of money to keep people employed, but investors are demanding a pound of flesh. This is why you see share prices surge after layoffs are announced.
3. web3/crypto zombie companies that aren't in dire financial straights yet, but may be pressured to return capital to investors given recent events in the space. You probably don't want to work here anyway.
4. Well-funded startups that raised recently and are actively growing. Any runway issues they have are far enough out that you don't need to worry much today.
So my advice is: Pick a startup that raised recently and is building something that looks like it could be a real business with appropriate margins. No web3 crypto scams, no uber-style businesses that can't grow without heavily subsidizing the cost of their service, etc.