T-SQL to show Azure SQL Managed Instance vs Azure SQL Database
To programmatically determine the engine edition, use SELECT
  SERVERPROPERTY('EngineEdition'). This query will return '5' for single
  databases/elastic pools and '8' for managed instances in Azure SQL
  Database.


https://docs.microsoft.com/en-us/sql/t-sql/functions/serverproperty-transact-sql?view=sql-server-2017