URL request blocking using selenium in JS

As a part of automation, I need to block a network call after the page is loaded to show an error. I know it can be done through chrome developer tools. Is there a way to use selenium and JS to force this?