The most common way of setting a cover image for any WordPress Page and Post to be used when it gets shared on Social Media platforms is by using specialized SEO plugins.
Besides the fact that a dedicated SEO plugin will help with the website's SEO optimization, it will also provide a simple way to add all the details used when a Page or a Post is shared on Social Media Platforms.
Our recommended SEO plugin is RankMath SEO.
Installing RankMath SEO plugin
Go to Dashboard > Plugins
Click on Add New
In the search box, type
In the search results list, click on it to install it
Once the RankMath plugin is installed, activate it.