Working in commercial insurance companies is haraam, even if the work is as a security guard, because that comes under the heading of cooperating in sin and transgression. Allah, may He be exalted, says (interpretation of the meaning):
“Help you one another in Al‑Birr and At‑Taqwa (virtue, righteousness and piety); but do not help one another in sin and transgression. And fear Allaah. Verily, Allaah is Severe in punishment”
See also the answer to question no. 40336
With regard to working as a security guard for a building or marketplace in which there is an insurance company, what appears to be the case is that it is permissible, because the insurance company in this case is only part of the building, and the basic principle is that there may be overlooked with regard to that which is part of something that which may not be overlooked otherwise.
So it does not matter that part of your salary may come from the money that the building owner gets from the insurance company, because your salary is in return for your work, which is permissible, as stated above.
And Allah knows best.