I don't think you can access another application's dock tile (not easily anyway). What OS are you running? If you can use AppleScriptObjC, a badge can be added to your own application's dock tile easily enough.
I have definitely had my terminal display badge icons, but it wasnt immediately obvious to me how it was done. My guess would be it based on the exit code of the utility. I bet with some google Kung foo you could make this happen.
AppleScriptObjC is a framework introduced in Snow Leopard 10.6 that lets you write Cocoa applications using AppleScript - it is the successor to the deprecated AppleScript Studio. In addition to Xcode, there are a couple of ways you can use ASObjC in a regular script - Lion's AppleScript Editor includes a Cocoa-AppleScript application template, and the background application ASObjC Runner. Both will run in Snow Leopard, although you will need a copy of the template from Lion to use that (the Cocoa-AppleScript template will need to be used in this case, since the application is referenced when getting the dock tile).
What exactly are you trying to do? Provide something like a progress bar?
Nope, essentially my Applescript application takes a user inputted variable and plugs it into a Terminal command. Everytime I use the application it opens a new Terminal window (intended). I would like to have a badge icon appear when a Terminal command completes.
I created a simple Cocoa-AppleScript example that sets and clears a badge on its dock tile, to see if that is what you are looking for. You can download it here - the main script is located in the application bundle's Contents/Resources/Scripts folder.
Alright, I have to admit I'm not a coder which is why I used Applescript since its so easy and logical. All the Applescript app does is open a Terminal window with the command and then it quits itself. I want the badge icon on the Terminal window not the Applescript app. Is that possible?
I don't think I've ever seen Terminal badging in 10.6.*. Or anything earlier, either. And I use Terminal a lot. In fact, it's an Open At Login item and sits in the middle of my Dock, and has been since 10.0.
In fact, those seem to be the only really relevant results at all.
Those posts to StackExchange clearly explain what causes Terminal badging (bell characters in output), on what OS version (Lion), and even give an example of how to produce it (sleep 3; printf '\a') on the relevant version of Terminal.
I see nothing at all about badging in Terminal on any other OS version. So off-hand, I'm going to guess "Not possible", but I'm perfectly willing to admit I lacked sufficient google-fu to produce the answer.
Badging isn't something you can do from another process. The process with the badge has to support badging itself. If it doesn't support badging, you can't make it show a badge. To put that in terms of Terminal, only Terminal.app supports badging (or not, before Lion). The processes you run in Terminal.app, like bash or sleep or printf, can only produce output on the pseudo-tty that Terminal itself interprets as a trigger to badge itself. This is a direct consequence of Terminal's support for badging, not something directly caused by those other processes. So without Terminal's ability to recognize bell characters and badge itself, no other process can tell Terminal to badge itself. It would require an in-process extension to do that (security issues), or trickery with Dock.app.
My application just puts a badge on its own dock tile, with a couple of dialogs to pause long enough to see the result (you can see the script by looking in the application bundle or by dragging the application onto the Script Editor). I am guessing that this is for feedback or status - is there a reason for wanting this particular kind of feedback?
As mentioned, I don't think there is a handy way to put a badge on another application's dock tile. I've looked around a bit and found Docktopus, so it looks like it can be done (in a fashion), although I'm not sure of the level of UI scripting or hackery required.