Делаем ровно то, что спрошено:
const result = Object.values(arr.reduce((acc, { id }) => (
(acc[id] ??= { id, count: 0 }).count++,
acc
), {}));
Или, решаем задачу в более общем виде:
function uniqueWithCount(data, key, countKey) {
const getKey = key instanceof Function ? key : n => n[key];
const unique = new Map;
for (const n of data) {
const k = getKey(n);
unique
.set(k, unique.get(k) ?? { ...n, [countKey]: 0 })
.get(k)[countKey]++;
}
return unique;
}
const result = Array.from(
uniqueWithCount(arr, 'id', 'count').values(),
({ id, count }) => ({ id, count })
);