You can modify your cookies using the ClientFunctions mechanism. These cookies will be added to further requests. This approach is safe, since every test in TestCafe starts with clear cookies, so cookies modification will not affect other tests.
I prepared an example, please see it:
import { ClientFunction } from 'testcafe';
const setCookie = ClientFunction(() => {
document.cookie = "myCustomCookie=myCustomValue";
});
fixture `fixture`
.page `http://google.com`;
test(`1`, async t => {
await setCookie();
await t.typeText('input[type=text]', 'test');
await t.debug();
});