Yes, you can group the funding from different departments through grouping attributes in a cost/budget plan. We can either setup departments(which can be funding sources to the project) and use those departments as grouping attributes to segregates those costs in a cost plan.
Alternatively, you can rely on User Lov 1 Lookup to setup custom funding source values and use User Lov 1 as a grouping attribute in a cost plan.
Regards
Praneeth