How can I programatically change the (D8 core) workflow state of an entity with Content Moderation?
A great example could be found in Content Moderation module's code.

$entity-&gt;set('moderation_state', $new_state);
if ($entity instanceof RevisionLogInterface) {
  $entity-&gt;setRevisionLogMessage($form_state-&gt;getValue('revision_log'));
  $entity-&gt;setRevisionUserId($this-&gt;currentUser()-&gt;id());
}
$entity-&gt;save();