you would need to replace the featured-image with page-attributes.

You cannot just copy that code into a file, you would need to modify it a bit:

wp.domReady( () => {
	var removeEditorPanel = wp.data.dispatch('core/edit-post').removeEditorPanel();

	// Remove featured image panel from sidebar.
	removeEditorPanel( 'page-attributes' );
} );

That should work. Now you need to add it to a JavaScript file that is loaded in the editor, for example, via the enqueue_block_editor_assets action.

Hope that helps!