How can I make error messages in admin

All you need is the correct html markup, namely a paragraph p inside a container div with a certain class. Usable classes are updated green, error & notice-error red, notice-warning orange, notice-info blue. Exemplary usage:

add_action( 'admin_notices', 'wpse330943_admin_notices' );
function wpse330943_admin_notices() {
  <div class="notice notice-error">
    <p>
      //some text
    </p>
  </div>
}