I know this is an old question, but you can do this using the ArcGIS Maps SDK for Javascript:
https://developers.arcgis.com/javascript/latest/sample-code/layers-imagerytilelayer/
https://gavinr.com/geometry-filter-tiled-layers-arcgis-javascript/