Yes – it should be fine if your dog was to eat a fly by accident.
They may not taste good for your dog but that is up to them to decide. However as mentioned above it shouldn’t hurt their health if they were to eat a fly.
But on the other hand it is important for dogs to stay away from stinging flies as they can hurt you and your dog. Having a sting on their tongue or elsewhere can be very painful for them and should be avoided.