<form>
  <my-ce name="foo"></my-ce>
</form>

<script>
  class MyCe extends HTMLElement {
    static formAssociated = true
    constructor() {
      super()
      this._internals = this.attachInternals()
    }

    connectedCallback() {
      this._internals.setFormValue('Hello, World!')
    }
  }
  customElements.define('my-ce', MyCe)
</script>

Create a form associated element.

Create a simple form associated custom element as described in Form associated element recipe.