Upgrading late 2011 MacBook Pro to SSD drive
If you bought Yosemite in the past, you can see if this version of OS X appears in the App Store as items you purchased. If so, you should be able to download the installer.

The instructions to create a bootable installer are given at the Apple web site: Create a bootable installer for OS X. Below, I have include a excerpt from this site.

Use the 'createinstallmedia' command in Terminal


Download the OS X installer from the Mac App Store. Quit the
installer if it opens automatically after downloading. The installer
will be in your Applications folder.
Mount your USB flash drive or other volume. You could also use a
secondary internal partition.
Open the Terminal app, which is in the Utilities folder of your
Applications folder.
Use the createinstallmedia command in Terminal to create the
bootable installer. Examples of this command are in the next
section. For detailed usage instructions, make sure that the
appropriate Install OS X app is in your Applications folder, then
enter one of the following paths in Terminal:


Path for El Capitan:

/Applications/Install\ OS\ X\ El\ Capitan.app/Contents/Resources/createinstallmedia


Path for Yosemite:

/Applications/Install\ OS\ X\ Yosemite.app/Contents/Resources/createinstallmedia


Path for Mavericks: 

/Applications/Install\ OS\ X\ Mavericks.app/Contents/Resources/createinstallmedia


Examples

This is the basic syntax of the command. Replace volume path with the path to your USB flash drive or other volume, and replace installer path with the path to the Install OS X app. 

createinstallmedia --volume volumepath --applicationpath installerpath


Example for El Capitan:

sudo /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume --applicationpath /Applications/Install\ OS\ X\ El\ Capitan.app


Example for Yosemite:

sudo /Applications/Install\ OS\ X\ Yosemite.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume --applicationpath /Applications/Install\ OS\ X\ Yosemite.app


Example for Mavericks:

sudo /Applications/Install\ OS\ X\ Mavericks.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume --applicationpath /Applications/Install\ OS\ X\ Mavericks.app


If you can not download Yosemite from the App Store.


  Note: What is written below has only been tested on Macs that are not using Core Storage.


Another alternative would be to create bootable USB flash drive OS X Recovery Disk. Basically, you would be coping your Recovery partition to a flash drive. You can the boot to this flash drive to download and install Yosemite on your SSD.

To create this Recovery Disk, you will need to download the OS X Recovery Disk Assistant v1.0. Even though Recovery Disk Assistant only refers to Lion and Mountain Lion, the Assistant will also work with Yosemite.

Using you HDD as the external bootable installer.

You could try purchasing USB external drive enclosure for your HDD. Or at least, purchase a SATA to USB adaptor. You then could try booting to the Recovery partition on the HDD. If successful, Yosemite could then be downloaded and installed on the new internal SSD.

If there is no way to perform a new installation of Yosemite.

This solution requires creating a El Capitan USB installer flash drive and connecting the HDD via a USB port.

Boot from the USB installer and launch the Disk Utility application. Create a partition on the new SSD. Restore the Yosemite partition from the HDD to the SDD. This is referred to as cloning.

Note the following:


The two drives may need to be using the same sector size. There are
only two sector sizes currently in use: 512 bytes and 4096 bytes.
You made need to reduce the size of the hard disk partition to be
smaller than the SSD partition. You may need to do this while booted
to Yosemite on the HDD.