I think I may have found some posts that could help you on that quest, UE4 create texture from C++ - Stack Overflow and UE4 - Save a procedurally generated texture as a new asset - Isara Tech. .
FTexture2DDynamicCreateInfo Texture2DDynamicCreateInfo;
Texture2DDynamicCreateInfo.Filter = Texture->Filter;
Texture2DDynamicCreateInfo.Format = Texture->GetPixelFormat();
Texture2DDynamicCreateInfo.bIsResolveTarget = false;
Texture2DDynamicCreateInfo.bSRGB = Texture->SRGB;
DynamicTexture = UTexture2DDynamic::Create(Texture->GetSizeX(), Texture->GetSizeY(),
Texture2DDynamicCreateInfo);
DynamicTexture->SetResource(Texture->GetResource());
DynamicTexture->SetFlags(Texture->GetFlags());
DynamicTexture->SetLinker(Texture->GetLinker(), Texture->GetLinkerIndex(), true);
DynamicTexture->SetExternalPackage(Texture->GetExternalPackage());
DynamicTexture->SetLightingGuid();
NewTexture = UTexture2D::CreateTransient(DynamicTexture->SizeX, DynamicTexture->SizeY, DynamicTexture->Format);
NewTexture->SetResource(DynamicTexture->GetResource());
NewTexture->SetFlags(DynamicTexture->GetFlags());
NewTexture->SetLinker(DynamicTexture->GetLinker(), DynamicTexture->GetLinkerIndex(), true);
NewTexture->SetExternalPackage(DynamicTexture->GetExternalPackage());
NewTexture->SetLightingGuid();
// NewTexture should be equal or similar to Texture
I’ve been trying to convert a Texture2D into a Texture2DDynamic and then create a new Texture2D from that Texture2DDynamic, but I’m not that familiar with textures and how they are built. This compiles, but whenever you want to look at it on the editor (select the actor in the world outliner) it crashes. I suspect it should be something similar but with the knowledge of the posts I linked before.