I solved this in c++.
Here’s the snippet code if you want and then just call it in blueprint.
#include "Runtime/Engine/Classes/Engine/TextureRenderTarget2D.h"
...
UFUNCTION(BlueprintCallable)
UTextureRenderTarget2D* CreateTexture(int32 width, int32 height, bool bForceLinearGamma, ETextureRenderTargetFormat format, EPixelFormat pxFormat = EPixelFormat::PF_FloatRGB)
{
UTextureRenderTarget2D* _renderTarget2D = NewObject<UTextureRenderTarget2D>();
_renderTarget2D->RenderTargetFormat = format;
_renderTarget2D->InitCustomFormat(width, height, pxFormat, bForceLinearGamma);
// add more customizations
return _renderTarget2D;
}