How do I set a cell via a formula in LibreOffice Calc?

Is there some function X such that X(cell or cell range,value) sets that cell or cell range to the value? If not, how would I do this via macros?

A Calc Cel function (formula) can modify the cell value only where the function was called from. (or a cell range - when you use an array function: the eresult can be located in more than one cells.)
If you want modify the value of some independent cells, then you must write a macro SUBROUTINE based on the API functions. Unfortunatelly you can not call these subroutines from a cell same way as the Cell functions you can call. You must launch them by an event: (by a menu item, by a hotkey, or by other events.

No - such one-time functions do not exist. If a cell (or a range) contains a function (formula) which would change the cell content from function to the result of the function’s evaluation, the cell (range) would no longer contain a function (formula) but a value - see what happens if you use Data -> Calculate -> Formula to Value.