No one is ever "indispensable to the project", and being smart isn't an excuse for being a jerk. Here's how we do it at my company -- you're given a talking to by your manager and a warning, if it continues it starts getting documented and you get fired.
We have a simple rule when hiring -- we don't hire jerks -- and we make that clear during the interview. Generally that self-selects people out and we end up with a team that is productive and cooperative. This is essential when building products, companies, or even coding as all of them are social interactions at their fundamental level.