Apple - How can I specify a custom icon for a Dock stack?

You need to change the icon of the folder that contains the items in the stack. This can be done in several ways, but perhaps the easiest is to start by navigate to the folder of the stack, change that icon, and set the stack to display the folder instead of the contents.

Click the stack, click "Open in Finder" in the stack, and then press the keystroke + . The key press will take you "one level up" in the directory hierarchy so that you are now looking at the folder that houses the items in the stack.

Next, select the folder (If it's not already selected), and "get info" on it, by typing + I, or right-clicking and selecting "Get Info". At the top of this window will be a miniature icon of a folder. You can click on this and copy it via the keyboard shortcut ( + C), or paste in an image that you copied from somewhere else.

Finally, you need to right-click on the stack and set it to display "folder" and not the stack contents.

You can't really. What you can do is add another item to the folder that has the custom icon, and then give it a name that would make it show up alphabetically first.

For example, this is a set of icons that make your stacks look like the files are in a box:

enter image description here

Right click (or ⌃ ctrl-click) the folder in the Dock, and select Display as: Folder from the menu that appears.