There is no general answer for this question. Do pilots observe religious fasts during flying? Some do, as this article notes:
... although Islam gave permission or leeway to break fast if one found it tiring during the flight, most pilots and cabin crew still chose to fast.
“So, I fasted for 10 hours 50 minutes, compared to 13 hours 42 minutes in Kuala Lumpur and 11 hours 11 minutes in Melbourne. Much shorter time than fasting in Melbourne, isn’t that interesting?
“However, on June 29, 2016, I will be flying to Jeddah. Jeddah residents will be fasting for 14 hours, 54 minutes while KL residents will fast for 13 hours 43 minutes. I will probably have to fast for 17 hours! This is when I have to be really patient. I may break my fast once I have landed.
For the safety of passengers and to ensure a smooth flight, if both pilots are Muslims, they take turns to eat, he said.
However, there is no way to tell for certain how many aircrew observe religious fasting, as this pilot may be talking about that particular airline, for example.
As for Can they observe religious fasting, it depends on the regulation and company policies. Most of the civil aviation authorities don't have anything specifically related to religious fasting, preferring to cover them under fitness for duty, though there is atleast one case where the regulatory authority explicitly forbid fasting.
Indonesia’s Directorate General of Civil Aviation ruled that all safety-sensitive aviation personnel must eat while on duty during Ramadan, the Islamic month of fasting