How can I ensure TRIM is enabled when installing Yosemite onto an SSD drive?
If you're running OS X on a HDD then I don't see how TRIM enters the equation, since TRIM is only for SSDs. If want to do a fresh install on the SSD, simply install it and proceed with your bootable USB, I do not see the problem.

What I did when installing the SSD was to put it in an enclosure, connect it via USB and  use Carbon Copy Cloner to clone the OS and some other stuff to the SSD, while leaving the big data (movies, music, etc.) on the HDD (which I then put in the optical bay). If you want to have certain parts of you user data on the HDD, you can create a symlink for that.

If you do not insist on a fresh install of OS X this is the way to go in my opinion.

EDIT:
A word on TRIM: 

The issue with TRIM on OSX is that it is supported only for SSD installed by Apple themselves. So to enable TRIM on third-party SSDs, one needs the Trim Enabler app which does it for you. All was fine until the release of Yosemite. The Trim Enabler App uses a so-called kernel extension or kext (I think this is more or less the same thing as a driver, but I'm not sure). With Yosemite, Apple introduced kext signing which means no kernel extensions will be loaded which are not signed (which can be done only by Apple). Now the developer of Trim Enabler has no way to get his extension signed (Apple would not do that because if they did, no one had to buy SSDs from Apple to get TRIM, a policy which I find appalling). 

The problem is that if you have TRIM enabled with the app and then try to boot a computer with kext signing enabled, it will refuse to boot since the TRIM extension is not signed. That makes it necessary to boot to recovery mode and disable kext signing from a command line.

So the only workaround is to disable kext signing altogether. This is a global setting, so it will apply to all possible kernel extensions which means you must be extra careful when installing drivers (which you probably never do on OS X) because it can't be verified they are trusted by Apple. But since the signing mechanism was only introduced in Yosemite, having it disabled does not put you more at risk than you were on Mavericks or before that.

The status of kext signing is saved in NVRAM, which can be reset accidentally (or manually). If reset, it will default to kext signing enabled and thus you will be unable to boot and must take the steps already outlined. 
Whatever you do, as long as you are able to boot into recovery mode, no permanent damage will arise from enabling TRIM.
But if you are not comfortable with the thought of having to go to recovery and type terminal commands, I would just stop worrying about TRIM and not use it, at the expense of some longevity and performance of your SSD.

All information on TRIM in conjunction with Yosemite is here. I do not know how this applies to you since you're on a HDD, but assuming that you have an SSD running with TRIM enabled through Trim Enabler, you should disable it before upgrading. 

I forgot to do that. What happened was that the installer ran successfully and I even got to the desktop afterwards, only after rebooting did the problem occur (grey stop sign at boot). I had no secondary computer to look up the commands listed in 2, but if you do, you can simply boot into recovery mode (hold CMD-R at boot) (either from your backup - which I hope you have - or from the Recovery HD if present, or the internet-based recovery), which will then allow you to open a terminal, run the commands, shut down and all will be working as kext signing will be disabled. You can then boot normally and choose to disable TRIM if you are uncomfortable with kext signing disabled (I see no reason to, since it did not exist before Yosemite) or just continue to use it.