All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah and that Muhammad is His slave and Messenger.
If what you mean is that the doctor treats patients who subscribed to the insurance and he gets his salary from the hospital that gets its payment for treatment and medicine from insurance companies, then the doctor is not sinful for treating those patients and he can benefit from his salary that is given to him in return for his lawful work.
The doctor takes his salary from the hospital in return for working as a doctor; so his salary is lawful because the salary is in return for his job (as a doctor).
As regards the issue of subscribing to health insurance, then its ruling depends on the type of insurance. It is permissible to subscribe to lawful health insurance for treatment and so forth, but it is not permissible to subscribe to unlawful insurance, which is the commercial insurance, except due to a necessity or dire need that should be estimated according to its proper value.
For more benefit, please refer to fataawa 82599and 92280.
Allaah knows best.