I think it depends on the race.
Most state at the bottom of the entry form whether or not they will refund money in certain situations.
A lot do not grant refunds for any reason (even if the race is cancelled!), but some do say that if you produce a doctors certificate you may be entitled to a refund.
The best thing to do is to contact the race secretary, or if there is a web site check with this.