Hi sds,
It may not be possible to do programmatically but you can use console.clear() when response status is 401 to hide, but that will lose anything in the console.
<script type="text/javascript">
window.onload = function () {
fetch("http://httpstat.us/401", {
requiredStatus: 'ok'
}).then(function (response) {
if (response.status === 401) {
console.clear();
}
}).catch(function () {
});
}
</script>