I think you’ll have to do it with C++.
See here or here.
The code from link #2:
//Adds a UActorComponent Subclass, that is based on the passed in Class, and added to the Outer(Actor) object
UActorComponent* UFSBlueprintFunctionLibrary::AddComponentByClass(TSubclassOf<UActorComponent> Class, UObject* Outer)
{
if (Class != nullptr && Outer != nullptr)
{
UActorComponent* Component = NewObject<UActorComponent>(Outer, *Class);
if (Component != nullptr)
{
Component->RegisterComponent();
return Component;
}
else
{
return nullptr;
}
}
return nullptr;
}