Yes. If you use libraries Isearch+ and Zones (including optional library isearch-prop.el), and you set option isearchp-query-replace-zones-flag. to non-nil, then replacement commands such as query-replace are limited to the buffer zones you define.
This works by binding isearch-filter-predicate to a function that recognizes the zones.
(Isearch works the same way - you can limit searching to defined zones. And if you use Bookmark+ then you can bookmark a set of zones.)
You can also query-replace (or search) the complement of a set of zones. Toggle this behavior using C-M-~ during Isearch.