When a widget instantiates, the map passes into it. As a result, you can access a map property in the postCreate or startup methods.
Modify the UI template and add a div tag to display the map ID property:
this.mapIdNode.innerHTML = 'map id:' + this.map.id;
For a 3D widget, the map property is replaced by sceneView. Use this.sceneView to access the scene in your widget.