To output block, you can attach which theme template will output it, which library to attach to it, what markup will be outputed and in the end what tags can be in this markup
public function build() {
$build = [];
$build['#theme'] = 'custom_block';
$build['#attached'] = array('library' => array('my_module/library_name'));
$build['custom_block']['#markup'] = '<div id="totle-widget"></div>';
$build['custom_block']['#allowed_tags'] = ['div','script'];
return $build;
}