Is it correct to say I work in an energy company? It's OK, and commonly said.
I Know that it is better to say I work for.. Yes, I'd say 'for' if I were speaking carefully.
but I am not sure if when you say I work for you have to mention the name of the company or it is not necessary? No, you don't have to mention the name.