private static void renameFragment(Program program, Address start, String name) {

		Listing listing = program.getListing();
		String[] treeNames = listing.getTreeNames();
		for (String treeName : treeNames) {
			boolean duplicate = false;
			int index = 0;

			ProgramFragment frag = listing.getFragment(treeName, start);
			do {
				try {
					frag.setName("Frag" + index + "-" + name);
					duplicate = false;
				}
				catch (DuplicateNameException exc) {
					duplicate = true;
				}
				index++;
			}
			while (duplicate);
		}
	}
Callback for merging blocks of memory
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/memory/MemoryMapManager.java