Gov . Mitt Romney will sign an agreement with the federal government Wednesday that gives the Massachusetts state police the authority to detain illegal immigrants and charge them with violating immigration law , his office said Tuesday .