I don't think there's any way of modifying this page as it's one of the standard error pages produced by the server. This error is generated before your code even gets a chance to run so there's nothing you can do to handle it.
The only thing you could do navigate to a different custom page first that uses a custom controller, that controller could then attempt to verify the ID and type in an init method, and then display an error if it fails or redirect to the existing page if successful.
The custom controller would look a little like this:
public class AccountIdChecker
{
public PageReference Init()
{
String acctId = ApexPages.currentPage().getParameters().get('Id');
if(acctId == '')
{
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'No id specified!'));
return null;
}
try
{
Id realAcctId = acctId;
if(Schema.Account.SObjectType != realAcctId.getSobjectType())
{
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'Id specified is not an account id!'));
return null;
}
}
catch (Exception e)
{
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'Bad id specified!'));
return null;
}
<<return reference to existing page here>>
}
}
And the page would be something simple, like this:
<apex:page controller="AccountIdChecker" action="{!Init}">
<apex:pageMessages/>
</apex:page>
In answer to the second part of your question, (Account)controller.getRecord();
will always return an account record (using the account standard controller), it'll be a new record if no ID was specified in the URL, or an existin gone if a valid ID is passed in, so you shouldn't need a try/catch block.