You have to return your formatted array. Change the code like below
function get_posttype_list() : array {
$pt_list = [];
$post_types = get_post_types( array( 'public' => true ), 'objects' );
foreach( $post_types as $pt ) {
$pt_list[ $pt->name ] = $pt->labels->singular_name;
}
return $pt_list;
}