The below Unit Test would verify the HttpStatusCode would set to 404. Note it must be set in your Controller's Action as you have in your question. If you expect the Web.config to interact it is more of a web integration test, which is completely a different test.
[TestMethod]
public void RouteWithTooManySegments()
{
var httpContextStub = new Mock<HttpContextBase>();
var httpResponseMock = new Mock<HttpResponseBase>();
var controllerContextStub = new Mock<ControllerContext>();
httpContextStub.Setup(x => x.Response).Returns(httpResponseMock.Object);
controllerContextStub.Setup(x => x.HttpContext)
.Returns(httpContextStub.Object);
var sut = new ErrorController
{ ControllerContext = controllerContextStub.Object };
sut.NotFound();
httpResponseMock.VerifySet(x => x.StatusCode = 404);
}