I finally figured it out for my Excel cell using custom conditional format using the code below. The key is to use getConditionalFormat("ID") with the ID being ID of the conditional format type. For custom type it is 0. I figured it out when reading the results of getConditionalFormats()
function main(workbook: ExcelScript.Workbook) {
const range = workbook.getWorksheet("Declaration").getRange("D56"); // Replace with your desired cell or range
// Retrieve the background color of the cell
const cellColor = range.getConditionalFormat("0").getCustom().getFormat().getFill().getColor()
// Log the background color
console.log(cellColor);
}