function my_custom_theme_widgets() {
    register_sidebar( array(
        'name' => 'My Widget',
        'id' => 'widget_id',
        'before_widget' => '<div class="widget_div">',
        'after_widget' => '</div>',
        'before_title' => '<h2>',
        'after_title' => '</h2>',
    ) );
}
add_action('widgets_init', 'my_custom_theme_widgets');

 

You can call widget via below:

<?php dynamic_sidebar('widget_id'); ?>