ArcGIDDynamicMapServiceLayer has a property called supportsDynamicLayers you can use to test this. Looks like this property has not been documented. I'll make sure it gets documented for the next release. In the meantime here's an example showing how this works.
var layer = new ArcGISDynamicMapServiceLayer("http://sampleserver5.arcgisonline.com/ArcGIS/rest/services/Energy/Geology/MapServer");
layer.on("load", function(){
console.log(layer.supportsDynamicLayers);
});
map.addLayer(layer);