How can I assign an icon to users depending on their gender?
Create a vocab as gender and add two taxonomies to it as male and female. To the gender vocab add image field and while creating the male and female taxonomy term add the respective images.

Now add the term reference file to user entity and keep it as stele list.

In your custom module hook_user_presave and get the value for the taxonomy field.when you know the selected taxonomy you can load the taxonomy to get the image field fid associated with it assign the fid to $user->picture.

Now everywhere image will load as per the gender selected.