Check if someone is editing a post (this content is currently locked)

Yes, there is a function in WP for that: wp_check_post_lock()

Give it the post ID and it will return the user ID that is currently editing the post OR false if no one is editing the post (i.e. it is not locked).

$is_locked = wp_check_post_lock( $post_id );

if ( false === $is_locked ) {

     // Post $post_id is not not locked for editing

} else {

     // Post is not locked, $is_locked contains the user ID who is editing.
     $user = get_user_by( 'id', $is_locked );
     echo 'Post id being edited by ' . $user->user_login;

}