Programmatically create user reference field
Check if Entity Reference Autocomplete  module helps you. The module page says


  This module defines a new form element type, called "entityreference",
  that allows developers to add autocomplete fields to forms, so that
  users can reference any entity in the same way they would do through
  an Entity Reference field.