Ruqiya Farah Yarow was killed outside her hut near the southern Somali town of Hosingow by gunmen belonging to the al-Shabab group, they say.
The militants had ordered her to put on a veil, and then killed her after returning and finding she was still not wearing one, the relatives said.
An al-Shabab spokesman denied the group had killed the woman.
Al-Shabab does not fully control the area where she was living, he added.
Relatives, who asked not to be identified for fear of reprisals, told the BBC that Mrs Yarow was killed at about 07:30 (04:30 GMT).
She was shot twice and died instantly, they added.
She is survived by her husband and children, the relatives said.
Al-Shabab, which controls much of southern and central Somalia, imposes strict rules of behaviour, including dress codes for men and women.
BBC Somalia analyst Mary Harper says the fact that al-Shabab has denied killing Mrs Yarow suggests that rogue elements within the group may have been responsible for her death.
It is also possible that al-Shabab wants to distance itself from the shooting because it is likely to provoke a strong public reaction, she says.