Ab initio Green's function calculation of hyperfine interactions for shallow defects in semiconductors