If you use the commandlet
Get-SPDatabase there are several properties of the returned object that can give you the information you need.
$db = (Get-SPDatabase)
Will print out the full server name, and I would assume instance, for that database. Another interesting property would be
That will print out something like
Data Source=SP2013;Initial Catalog=SP2013_State_Service_DB;Integrated Security=True;Enlist=False;Pooling=True;Min Pool Size=0;Max Pool Size=100;Connect Timeout=15
Data Source will contain the full server and instance name as well. I'll convert that code for you and add it as an edit.
Here is the code on the link you gave converted to PoSh. I have not wrapped it in a function as I am not sure how you might want to use it...
if ( (Get-PSSnapin -Name microsoft.sharepoint.powershell -ErrorAction SilentlyContinue) -eq $null )
$farm = Get-SPFarm
foreach ($server in $farm.Servers)
foreach ($svc in $server.ServiceInstances)
if($svc -is [Microsoft.SharePoint.Administration.SPDatabaseServiceInstance])
$s = [Microsoft.SharePoint.Administration.SPDatabaseServiceInstance]$svc;
$svc.DispalyName + "\" + $s.Instance