it would be doable in any context outside the Attribute Editor -- but unfortunately it's a lot harder inside the AE.
Attribute Editor UI is generated in MEL and is a little different than ordinary MEL UI (the kind you write for yourself). In particular, there's already a right click menu on the labels inside the attribute editor -- the one that lets you set expressions or connect attributes -- and it's buried somewhere inside the attribute editor MEL (that will be in the scripts folder inside your Maya installation). Even if you can get the underlying widgets there's no easy way to find and disable or extend the existing popup menu; it's buried in there somewhere but exactly where is hard to say: the old-school MEL trick of using a text search of all the scripts in the folder is probably not going to work because many of the visible labels on the UI are now inside of separate resource files to support internationalization -- good for non English customers, but it means that searching for "Create New Expression..."
doesn't find the AE popup menu script. While it's not literally impossible -- that UI is getting created somewhere -- it's probably not a good value for your time investment.
If you're only interested getting a script to run on the object that's currently visible in the AE, this will get you the name of the active item:
cmds.nameField('AEnodeNameField', q=True, o=True)
That'll get you whatever is showing in the main AE editor -- though if nothing is selected (so the AE appears empty) it will still return the last item that was in the AE.