There are many ways as others mentioned such as quality of whitepaper, website, authenticity of team, advisors, presence of institutional backing etc. But unfortunately, you'll never truly know until after the ICO is concluded.
You can have an ICO with the best presentation, and still turn out to be a scam. Why?
There are cases of which seemingly legit ICOs with good quality presentation exit without returning investors' fund, simply because they can't raise enough money during ICO. People lose interest in this bear market and the number of ICO investors declines sharply. And unfortunately when these ICO founders are hit by the harsh reality which they weren't prepared due to their plain ignorance and over confidence - very common in the blockchain industry, they change their mind and decide to "recover the loss" and "save their ego" by taking away whatever investor's fund, instead of returning they money and acknowledging their failure and incompetence.
Do a google search "legit ICO turn to exit scam" and you'll find out the unpleasant fact.
Probably the only ICOs giving you more confidence are the ones run by established "conventional" businesses instead of blockchain startups. Even if their ICOs fail, it's more likely they'll return your fund, because they are well established businesses, and so less likely to risk their existing reputation by scamming.
But who knows, even these established businesses may still keep your money - they won't exit, but will come up with some shameless excuses (some of which have been already demonstrated, like "you failed to pass KYC / AML / identity check / xxxx compliance" or "blockchain technical issues"), if they are really desperate in getting profit. Remember even Coinbase (and some other crypto exchanges) have a notorious history of "disappearing" customers' deposits, which saw a surge during the crypto mania in 2017. If this happens, your only hope remains in a class action.