Don't know if any of these are the William you seek but here are three references to a William Carlyle from the MIs for Ecclefechan Graveyard in Hoddam Parish, Dumfriesshire. Carlyle burials are found in all of the main four graveyards in Hoddam Parish.
1. Here lyes Helen CARLYLE, daughter to William CARLYLE in Middlewhats, who died 3rd August 1775 aged 1 year and 3 months
Also William CARLYLE, his son, who died 8th July 1777 aged 2 years and 3 months
2. In Memory of William CARLYLE, who died in Eaglesfield 18th June 1857 aged 74 years
Also Mary CARRUTHERS, his spouse, who died 13th May 1862 aged 84 years And Margaret, their daughter, who died in Boston, America, 29th November 1845 aged 31 years
Also Robert, their son, who died 18th June 1846 aged 27 years at Meinmill
3. In Memory of William CARLYLE in Sandbed, who died 9th January 1776 aged 64 years
Also Ellen BLACK, his wife, who died 28th December 1775 aged 63 years
Also Ellen, daughter of Robert CARLYLE in Trailtrow, their son, who died 20th December 1785 aged 13 months And the said Robert CARLYLE, who died there 16th September 1797 aged 55 years Also Martha RAE, his wife, who died there 1804 aged 66 years
Also Martha, daughter to William CARLYLE in Trailtrow, son of the above Robert CARLYLE, who died 1814 aged 2 years
Also Jane BRYDEN, his wife, who died at Williamwath 1825 aged 36 years
And the said William CARLYLE, who died at Gibsonshill, Tundargarth, 19th June 1857 aged 74 years