1) For apps downloaded from the iTunes store only--copy the custom icon to /private/var/mobile/Applications/***/<appname>.app/, where *** represents a unique app ID number and "<appname>.app" is the name of the app program (e.g., Shazam.app). Note that you'll have to drill through each app ID # directory in order to find the app whose icon you wish to replace since it's not easy to determine the name of the app just from looking at the app ID #. The stock icon file is usually named "icon.png" or "Icon.png" but may vary for some programs; in any case, you may want to make a backup of the stock icon file before you overwrite it (just rename the existing "icon.png" file "icon.bak" or similar so that you can revert back to the original icon if need be.
2) For apps downloaded via Cydia or similar post-jailbreak appstore tool--similar to #1 except you need to drill down to /private/var/stash/Applications.******, where ****** is a bunch of characters...so, "Applications.vo2HKG" (the string may/will be different on your phone). Once in that directory, find the dir that has the app name you're looking for, drill into that directory, and then perform the same icon backup and copy procedures as described in #1.
You will need to respring or reboot your iPhone once you've copied over your custom icons in order for them to take effect.
There is another way to perform this task that doesn't involve doing anything in either/both of the application directories mentioned above (i.e., overwriting the original stock icon file), but does require that you have Winterboard installed and the creation of a custom Winterboard theme and some subdirectories for each and every app whose icon you wish to replace...lemme know if you're interested on how to do it that way.