Scale line control is an HTML element, so you really cannot do that as is. You need to draw a line on the map canvas itself and after each map move, update that line denoting the actual length in map units.
Assuming you are using a metric projection, a 50 pixel line at a 0.2 resolution denotes
50px x 0.2m/px = 10m
Check the link here for exporting a map to PNG:
https://openlayers.org/en/v4.6.5/examples/export-map.html
I modified the code so as to draw a 200 meter long line on the canvas and denote the scale by writing 200m over it. It is quick and dirty, but should point you in the direction.
// this example uses FileSaver.js for which we don't have an externs file.
var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
}),
new ol.layer.Vector({
source: new ol.source.Vector({
url: 'https://openlayers.org/en/v4.6.5/examples/data/geojson/countries.geojson',
format: new ol.format.GeoJSON()
})
})
],
target: 'map',
controls: ol.control.defaults({
attributionOptions: {
collapsible: false
}
}),
view: new ol.View({
center: ol.proj.transform([28.9, 41.1],"EPSG:4326","EPSG:3857"),
zoom: 18
})
});
document.getElementById('export-png').addEventListener('click', function() {
map.once('postcompose', function(event) {
var canvas = event.context.canvas;
var ctx = canvas.getContext("2d");
ctx.strokeStyle = "#0000FF";
ctx.lineWidth = 5;
ctx.beginPath();
ctx.moveTo(10, map.getSize()[1]-10);
ctx.lineTo(200/map.getView().getResolution(), map.getSize()[1]-10);
ctx.stroke();
ctx.font = "20px Arial";
ctx.fillText("200m", 10, map.getSize()[1]-10);
if (navigator.msSaveBlob) {
navigator.msSaveBlob(canvas.msToBlob(), 'map.png');
} else {
canvas.toBlob(function(blob) {
saveAs(blob, 'map.png');
});
}
});
map.renderSync();
});