Yes you can create a user with wp_create_user() function.
This is how you create an admin user account. You need to add the following codes in your theme's functions.php file.
add_action('init', 'add_new_user');
function add_new_user() {
$login_name = "my_custom_user";
$password = "My_Password";
$email = "email@example.com";
if (! username_exists( $login_name )) {
$user_id = wp_create_user( $login_name, $password, $email );
// Get current user object
$user = get_user_by( 'id', $user_id );
// Remove subscriber and add administrator role
$user->remove_role( 'subscriber' );
$user->add_role( 'administrator' );
}
}
See the documentation to learn more - https://developer.wordpress.org/reference/functions/wp_create_user/