In this case it seems a block pattern might suffice. The Group block has a templateLock
attribute which can be set to all
to prevent any additional blocks from being inserted within and also keep the Heading and Paragraph blocks from being moved or deleted.
Here’s an example with the template lock and a custom class added to the Group block.
add_action( 'init', function(){
register_block_pattern(
'my-plugin/dually-heading',
[
'title' => __( 'Heading with sub-heading', 'my-plugin' ),
'categories' => [ 'header' ],
'content' => <<<MARKUP
<!-- wp:group {"templateLock":"all"} -->
<div class="wp-block-group dually-heading">
<!-- wp:heading --><h2>Get some at HUD</h2><!-- /wp:heading -->
<!-- wp:paragraph --><p>The candy store of covert revenues</p><!-- /wp:paragraph -->
</div>
<!-- /wp:group -->
MARKUP
]
);
} );