I found this M2 Shipping Module helped me manipulate the shipping methods to suit my needs. I built to exclude delivery to certain postcodes and also use a custom attribute to set the method's price.
update (in light of question)
I guess it needs to install properly first but based on your question you might look at modifying something like these suggestions from the documentation
addMethod('id_005', [
'title' => "France, Germany, Switzerland, Spain, Italy",
'enabled' => in_array($request->dest_country_id, ['FR', 'DE', 'CH', 'ES', 'IT']),
'price' => 10,
]);
addMethod('id_006', [
'title' => "Postcode starting with 25",
'enabled' => $request->dest_country_id == 'FR' && substr($request->dest_postcode, 0, 2) == '25',
'price' => 10,
]);
addMethod('id_007', [
'title' => "Regular expressions allowing postal codes beginning with 'PO' (case insensitive)",
'enabled' => $request->dest_country_id == 'GB' && preg_match('/^PO.*$/i', $request->dest_postcode),
'price' => 10,
]);
Best Answer
Override
checkAvailableShipCountries()
atHere you can get city, state, country etc from
\Magento\Framework\DataObject $request
Use
$this->_rateErrorFactory
for display errorFinal Code: