With the "extra code" feature you can set additional HTML/JS/CSS code for a shortcode. This extra code will be inserted at the bottom of the page when that shortcode is used on the page anywhere at least once.
If the shortcode is not used then it the extra code won’t be inserted. Also, the extra code will be inserted only once on page even when the shortcode is used multiple times on the page.
Setting extra code
The extra code option is available in the shortcode editing page under the "Shortcode settings" metabox.
Is it possible to insert extra code at the top of the page i.e inside
No, it is not possible to do that. Extra code will be inserted only at the bottom of the page. Since shortcodes can be inserted at any place in a page, it is not possible to insert extra code ahead at the top of the page.