Scriptable menu bar icons
I would suggest starting with this thread, which describes using Cocoa Objective-C calls from within AppleScript. There is an example Xcode project here.

And Launch is a complete application written in AppleScript that functionally does this. Its Xcode project file is here.

The basic premise is to generate NSMenuItem instances and add them to the system's NSStatusBar:

set statusMenu to (NSMenu's alloc)'s initWithTitle_("Launch")
-- (build and do stuff with the statusMenu here)
set sysStatusBar to NSStatusBar's systemStatusBar
set statusItem to sysStatusBar's statusItemWithLength_(32)
tell statusItem to setMenu_(statusMenu)
tell statusItem to setHighlightMode_(1)
set menuImage to NSImage's imageNamed_("icon.png")
tell statusItem to setImage_(menuImage)


AppleScript excerpt from Launch's source code, Copyright &copy; Lee Hanken