Hoping I have understood well your issue, you may set the text from a specified field as Legend by directly creating the categorized style.
Assuming to start from this self-explanatory Attribute Table:

you may assign the "DSCR_UCF"
field as Legend for the "ID_UCF"
values using the following code from the Python Console:
from PyQt4.QtGui import *
import random
layer = iface.activeLayer()
my_dict = {}
for feat in layer.getFeatures(): #iterate over the features for defining the lookup: value -> (color, label)
if feat["ID_UCF"] not in my_dict.keys():
color = QColor.fromRgb(random.randint(0,255),random.randint(0,255),random.randint(0,255)) #assign a random color
my_dict[feat["ID_UCF"]] = (color.name(), feat["DSCR_UCF"]) #lookup: value -> (color, label)
else: # go to the next feature since the label is already stored
continue
# Create a category for each item in my_dict
categories = []
for value, (color_name, label) in my_dict.items():
symbol = QgsSymbolV2.defaultSymbol(layer.geometryType())
symbol.setColor(QColor(color_name))
category = QgsRendererCategoryV2(value, symbol, label)
categories.append(category)
# Create the render and assign it to the layer
renderer = QgsCategorizedSymbolRendererV2("ID_UCF", categories)
layer.setRendererV2(renderer)
layer.triggerRepaint()
You will get this result:

EDIT
If you want to keep the original colors unchanged, you may run the following code (assuming you previously assigned a custom categorized renderer with custom colors):
from PyQt4.QtGui import *
layer = iface.activeLayer()
f_index = layer.dataProvider().fieldNameIndex('ID_UCF')
unique_values = layer.uniqueValues(f_index)
rend = layer.rendererV2()
colors = [symb.color().name() for symb in rend.symbols()]
diz = dict(zip(unique_values, colors))
my_dict = {}
for feat in layer.getFeatures(): #iterate over the features for defining the lookup: value -> (color, label)
if feat["ID_UCF"] not in my_dict.keys():
val = [diz[feat["ID_UCF"]]]
val.append(feat["DSCR_UCF"])
my_dict[feat["ID_UCF"]] = tuple(val) #lookup: value -> (color, label)
else: # go to the next feature since the label is already stored
continue
# Create a category for each item in my_dict
categories = []
for value, (color_name, label) in sorted(my_dict.items()):
symbol = QgsSymbolV2.defaultSymbol(layer.geometryType())
symbol.setColor(QColor(color_name))
category = QgsRendererCategoryV2(value, symbol, label)
categories.append(category)
# Create the render and assign it to the layer
renderer = QgsCategorizedSymbolRendererV2("ID_UCF", categories)
layer.setRendererV2(renderer)
layer.triggerRepaint()