Nope. This expression does not have anything to do with loyalty as dogs have often been exemplified to be. It just means to work very hard. " I worked like a dog to finish my assignment on time". There is a word called doggedly (adv) which also contain the part 'dog' and it has also a similar meaning.It means to work hard inspite of difficulties. Here again there isn't any connotations of loyalty. :)