For the record and per kind request by user2651192, the most workable path for this that we could find is here and, more specifically, the code to change the text is:
...
node.append("text")
.text(function(d){ return d.name; })
.on('click', function(d){
var result = prompt('Change the name of the node',d.name);
if(result) {
d.name = result;
var node1 = canvas.selectAll('.node').data(nodes);
node1.select('text')
.text(function(d){ return d.name; });
}
)};
...