I've run out of ghee and it's hard to get where I am. Will coconut oil be a good substitute when frying off onions and spices?
Coconut oil has a low smoke point (177-204C depending on processing). Ghee has a smoke point of 252C. The effect of this is that it will be quite hard to stop the oil burning.
But that's not to say it would be impossible - softening onions and garlic in butter or olive oil is common, and they have lower smoke points still. But the texture from frying at a lower temperature will be quite different. It may also affect the flavour of your spices.
In addition, the coconut oil will change the character of your curry significantly. That may not be a bad thing.
(all figures from Wikipedia)
Coconut oil is used quite regularly in the southern part of India. It completely replaces ghee or sunflower oil in certain dishes. And as Chris pointed out, it definitely changes the overall flavor of your dish and it may not be a bad thing if it doesn't conflict with the rest of the flavor profile. As for the original question of frying onions, you surely can but they don't end up very crispy but on caramelization you have a sweet, soft textured onion.