Angela Merkel has warned Britain will have a "price" to pay if it restricts EU immigration post-Brexit.