Current post categories and subcatecories outside of the loop

You can use this in your sidebar.php. I highly recommend you to use a child theme.

Here is a minimum example of such a tag list. you can also make a widget out of it. Learn here.

And add html based on your theme’s design structure.

<ul>
<?php 
$terms = wp_get_post_terms( get_queried_object_id(), 'taxonomy-name-here' );
foreach($terms as $term){
?>
    <li>
        <a href="https://wordpress.stackexchange.com/questions/360314/<?php echo get_term_link( $term ); ?>"><?php echo $term->name; ?></a>
    </li>
<?php } ?>
</ul>