Yes, what you want to implement is cards. This is basically the concept of injecting metadata into your site that tells Twitter how you want it to be presented. If you wanted to do it using code, you could implement it doing something like this (barebones version):
add_action( 'wp_head', 'wpse_add_twitter_metadata' );
function wpse_add_twitter_metadata() {
global $post;
printf(
'<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="%s" />
<meta name="twitter:description" content="%s" />
<meta name="twitter:image" content="%s" />',
get_the_title( $post ),
get_the_excerpt( $post ),
get_the_post_thumbnail_url($post)
);
}
With that configured, when someone goes to share your page with web intent or by copying and pasting the URL, Twitter should have the information it needs to generate the proper preview. With that said, I’d rely on a plugin to do something like this, personally. Social media API’s and integrations like this are always changing and a free plugin like Yoast SEO will handle this for multiple social networks without having to implement it yourself.