I think it's kind of like dating: if they don't give you an obvious signal, you probably won't know until it's too late, and sometimes when you get an "obvious" signal you might be wrong anyway.
The only advice I can think of--beyond heeding obvious warning signs--is to try to work some place that's doing something you actually care about. Then you're less likely to run into incompatibility issues, and the effect of toxic people may be mitigated.
Another angle is that you probably can't avoid working with assholes, so you can get organized and be prepared to push your own agenda. Don't back down too easily. I've seen this work fairly well, but you have to be ready to deal with the stress and potential fallout. Depends on circumstances, YMMV, etc.