Can I use multiple gmail-based accounts with the same username (but different domains) with Mail.app & IMAP?
Follow these steps:


Open Mail and delete each of the conflicting accounts. Close Mail.
Go to ~/Library/Mail/ and make sure any IMAP-username123@imap.gmail.com folder has been deleted. If there is any such folder left, delete it now.
Open Mail and create one of the accounts and let Mail load your messages. Close Mail.
Go to ~/Library/Mail/ and verify that a folder called IMAP-username123@imap.gmail.com has been created.
Open ~/Library/Preferences/com.apple.mail.plist. If you have installed Xcode, this file will open with Property List Editor. Otherwise you can download a free trial of PlistEdit Pro to open this file. Using a plain text editor with .plist files is more difficult.
With the .plist file open, click the disclosure triangle for MailAccounts. Here you will find Item 0, Item 1, etc.
If you click the disclosure triangle for each of the Item headings, you will find that one of them has the value username123@gmail.com or username123@company.com for the AccountName key, depending on which account you created in step 3.
Change the value for AccountPath for this Item so that the path will not collide with that of the next account you are to create.
Save and close the .plist file.
Open Mail and let it reload your messages. Close Mail.
Go to ~/Library/Mail/ and verify that a folder with the path value you provided in step 8 has been created. Delete the old folder called IMAP-username123@imap.gmail.com.
Open Mail and create the remaining account normally and let Mail load your messages.