So English phrase "They have cooked rice" can be translated as "wanakuwa na ugali" and "Wamepika wali", depends on meaning?)
ugali is not rice. 'Wanakuwa na ugali' is a bit of an odd sentence. It would translate to 'they are with ugali/they are being with ugali'. 'Wamepika wali' is pretty much the only translation of 'they have cooked rice'