How do I set a VisualElement's content container in C# code?

Override the contentContainer property to point to a child element.
Then use hierarchy.Add() to attach the content container (and any other elements) to the parent.

class MyElement : VisualElement
{
  public new class UxmlFactory : UxmlFactory<MyElement> { }

  public override VisualElement contentContainer => _container;
  private VisualElement _container;

  public MyElement()
  {
    _container = new VisualElement();
    _container.name = "content-container";
    hierarchy.Add(_container);
  }
}