Plugin. Html code in Template

One way to do that is to define a function, which either echos or returns stuff, in your plugin file and then use that function in your theme files when needed.

For example in your my-awesome-plugin.php

function hello_world() {
    echo 'Hello world!';
}

And then in your theme file, let’s say single.php

// safety check if your plugin ever gets disabled
if ( function_exists( 'hello_world' ) ) {
    hello_world();
}

This would result in Hello world! on your single post.

Then it’s up to you to decide what kind of stuff you want to return or echo with the function you’ve defined in the plugin file. It could be a string of html, integer, array, object, whatnots…

Do these examples help you with your situation?

EDIT Now as I read again your question right after posting, I realized that I might have misunderstood it and answered it improperly.

Perhaps you can define a class in your plugin file and store data in it. Then have a function return single instance of it. Same way that WooCommerce does it.

From https://github.com/woocommerce/woocommerce/blob/master/woocommerce.php

function wc() {
    return WooCommerce::instance();
}

Regarding class initialization there’s good answers here, Best way to initiate a class in a WP plugin?