Set label of $entity programmatically in a custom form
It's not clear what entity type you have. In the question you ask for the label of a content type, which would be the entity node, then the label field is title. In the question title it is a more general question about the label of an entity and in the code you redirect to a group_content entity route, which would suggest this is another entity type.

In this case, if you don't know the entity type, you could use this generic code to get the label field name and set the label with it:

$label_field = $entity-&gt;getEntityType()-&gt;getKey('label');
$entity-&gt;set($label_field, 'New label');